Reputation: 1888
Okay, all I would like to do is produce a nice bar chart of the populations of the Countries of the World.
pop_list = pd.read_table('country.dat', names=cols)
pop_list.dtypes
# Rank int64
# Country object
# Population object
print(type(pop_list['Population']))
pd.Series.hist(pop_list['Population'])
gives an error: TypeError: unorderable types: str() < float()
pop_list.plot.hist(['Population'],alpha=0.5)
plt.show()
makes a rubbish plot, presumably of 'Rank', and finally
pop_list['Population'].plot().hist()
gives: TypeError: Empty 'DataFrame': no numeric data to plot
Upvotes: 0
Views: 892
Reputation: 862671
After data answer is different - need parameter thousands
:
cols = ['a', 'b', 'c', 'd']
pop_list = pd.read_table('country.dat', names=cols, thousands=',')
print (pop_list)
a b c d
0 World World World 7432663275 7349472099 +1.1%
1 China Asia Eastern Asia 1382323332 1376048943 +0.5%
2 India Asia Southern Asia 1326801576 1311050527 +1.2%
3 United States Americas Northern America 324118787 321773631 +0.7%
4 Indonesia Asia South-Eastern Asia 260581100 257563815 +1.2%
print (pop_list.dtypes)
a object
b int64
c int64
d object
dtype: object
Upvotes: 1