Reputation: 1684
I am trying to get shape of a dataframe. I read the data from from a csv file to a dataframe using pd.read_csv and then am trying ro get its dimensions.
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
How to resolve it???????
print(type(data))
<class 'pandas.core.frame.DataFrame'>
Upvotes: 7
Views: 10426
Reputation: 511
The error is because shape() throws error, the correct way is without parenthesis.
If you change:
print(data.shape())
For:
print(data.shape)
It will print the shape of data
Do you really need the second: with open... ? Pandas can load without the with open line
Upvotes: 13