如何在没有索引的情况下打印pandas DataFrame

[英]How to print pandas DataFrame without index


I want to print the whole dataframe, but I don't want to print the index

我想打印整个数据帧,但我不想打印索引

Besides, one column is datetime type, I just want to print time, not date.

另外,一列是datetime类型,我只想打印时间,而不是日期。

The dataframe looks like:

数据框如下所示:

   User ID           Enter Time   Activity Number
0      123  2014-07-08 00:09:00              1411
1      123  2014-07-08 00:18:00               893
2      123  2014-07-08 00:49:00              1041

I want it print as

我希望它打印为

User ID   Enter Time   Activity Number
123         00:09:00              1411
123         00:18:00               893
123         00:49:00              1041

3 个解决方案

#1


87  

print df.to_string(index=False)

#2


15  

print(df.to_csv(sep='\t', index=False))

Or possibly:

或者可能:

print(df.to_csv(columns=['A', 'B', 'C'], sep='\t', index=False))

#3


1  

If you just want a string/json to print it can be solved with:

如果你只想要一个字符串/ json打印它可以解决:

print(df.to_string(index=False))

打印(df.to_string(指数= FALSE))

Buf if you want to serialize the data too or even send to a MongoDB, would be better to do something like:

如果你想序列化数据或甚至发送到MongoDB,最好是做以下事情:

document = df.to_dict(orient='list')

document = df.to_dict(orient ='list')

There are 6 ways by now to orient the data, check more in the panda docs which better fits you.

现在有6种方法来定位数据,在更适合您的熊猫文档中查看更多内容。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2014/07/09/37b1bdc5a3fb531c60bccb5124faf24.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号