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 ...
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.