#!/usr/bin/env python # coding: utf-8 # In[1]: ''' 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') # In[2]: cols = ['Rank', 'Country', 'UN_Continental_region', 'UN_Statistical_region', 'Population', 'Population2015', 'percent_change'] # In[3]: ## 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') # In[4]: pop_list = pd.read_table('country.dat', names=cols) # In[5]: #print(type(pop_list)) #pop_list.head() pop_list.dtypes #pop_list.describe() # In[6]: #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') # In[7]: plt.show() # In[ ]: