【发布时间】:2018-06-30 03:08:26
【问题描述】:
我正在尝试使用以下代码查看 csv 文件:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv("/Users/tristanshah/Desktop/trainingandtestdata/training.1600000.processed.noemoticon.csv", header=None, names=['sentiment', 'id', 'date', 'query_string', 'user', 'text'], encoding='ISO-8859-1')
print(df.head())
如果我运行它,它会返回:
...
0 ...
1 ...
2 ...
3 ...
4 ...
[5 行 x 6 列]
如何显示整个数据框?
【问题讨论】:
-
使用 print(df.head()) 代替 print(df)
-
df.head()仅显示前 5 行print(df) -
当我 print(df) 它打印所有 1600000 行但只打印第一列。
标签: python python-3.x pandas csv