【发布时间】:2020-06-11 10:46:01
【问题描述】:
背景
我正在尝试获取数据框的形状。我使用 pd.read_csv 将数据从 csv 文件读取到数据帧,然后尝试获取其尺寸。
代码
file_name = 'xxxxxx.csv'
with open(file_name, 'r') as f:
metadata_location = [i for i, x in enumerate(f.readlines()) if 'Metadata' in x]
with open(file_name, 'r') as f:
data = pd.read_csv(f, index_col=False, skipfooter=26)
print(data.shape())
错误
TypeError: 'tuple' object is not callable
怎么解决??????
其他检查
print(type(data))
<class 'pandas.core.frame.DataFrame'>
【问题讨论】:
-
直接调用
data = pd.read_csv(file_name, index_col=False, skipfooter=26)不打开 -
再次出现同样的错误 'TypeError: 'tuple' object is not callable'
-
去掉形状后面的 ()。它是一个属性而不是类方法
标签: python pandas dimensions