'''
https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)
'''
import pandas as pd
import numpy as np
import matplotlib as plt
import matplotlib.pyplot as plt
plt.style.use('ggplot')
cols = ['Rank', 'Country', 'UN_Continental_region', 'UN_Statistical_region',
'Population', 'Population2015', 'percent_change']
## There is problem your numeric data contains bad data (strings) or numeric data are converted to str.
## So first try convert to float or int by astype:
#pop_list['Population'] = pop_list['Population'].astype(float)
## But if it failed need to_numeric with parameter errors='coerce':
#pop_list['Population'] = pd.to_numeric(pop_list['Population'], errors='coerce')
pop_list = pd.read_table('country.dat', names=cols)
#print(type(pop_list))
#pop_list.head()
pop_list.dtypes
#pop_list.describe()
Rank int64 Country object UN_Continental_region object UN_Statistical_region object Population int64 Population2015 int64 percent_change object dtype: object
#pop_list['Population'].plot().hist('Population')
pop_list['Population'].plot().hist(alpha=0.5)
#pop_list.plot.hist(alpha=0.5)
#pop_list.plot.hist('Population')
/Users/npr1/astroconda/lib/python3.5/site-packages/ipykernel/__main__.py:2: RuntimeWarning: Tried to set a label via parameter 'x' in func 'hist' but couldn't find such an argument. (This is a programming error, please report to the matplotlib list!) from ipykernel import kernelapp as app
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-6-b77294b82800> in <module>() 1 #pop_list['Population'].plot().hist('Population') ----> 2 pop_list['Population'].plot().hist(alpha=0.5) 3 #pop_list.plot.hist(alpha=0.5) 4 #pop_list.plot.hist('Population') /Users/npr1/astroconda/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs) 1890 warnings.warn(msg % (label_namer, func.__name__), 1891 RuntimeWarning, stacklevel=2) -> 1892 return func(ax, *args, **kwargs) 1893 pre_doc = inner.__doc__ 1894 if pre_doc is None: TypeError: hist() missing 1 required positional argument: 'x'
plt.show()