Reputation: 123
What I have tried so far is to iterate through the dataframe columns and then use the control variable in the df.<columnName>.describe()
function, but this doesn't seem to work...
for (columnName, columnData) in df.iteritems():
print('Column Name: {}'.format(columnName))
column_stats = df.columnName.describe()
This is the output :
attr__ return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'columnName'
Can someone help me with this rather trivial doubt ...
Upvotes: 0
Views: 92
Reputation: 2819
Try it:
for columnName, columnData in df.iteritems():
print('Column Name: {}'.format(columnName))
column_stats = df[columnName].describe()
df.columnName is searching for a Column Name ColumnName not the value of your variable
Upvotes: 2