Reputation: 61
This code :
import pandas as pd
data = pd.read_csv('house', sep="\t", header=None)
data.columns = ['label', 'msg']
data['msg_length'] = data['msg'].apply(lambda x: len(x))
data['msg'].hist(column =data['msg_length'], by=data['label'], bins=50)
Gives me this error:
AttributeError: 'Series' object has no attribute 'columns' `
I have tried different things with pd.DataFrame and pd.Series, without luck. What do i wrong?
Error code:
Upvotes: 1
Views: 21474
Reputation: 862611
Use DataFrame.hist
with columns in strings instead Series
like data['msg_length']
:
data.hist(column ='msg_length', by='label', bins=50)
Upvotes: 1