In [87]:
import matplotlib.pyplot as plt
import json
import pandas as pd
import numpy as np
%matplotlib inline
In [88]:
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
Out[88]:
In [6]:
f = pd.read_csv('/home/ch/edx_note/edx_data.csv')
In [7]:
f.columns
Out[7]:
In [8]:
nation = f['final_cc_cname_DI']
In [11]:
count_nation = nation.value_counts()
print count_nation
In [76]:
count_nation.plot(kind='barh',title='nation count',figsize=(8,6),legend=True,grid=True)
plt.savefig('/home/ch/pycharm_code/edx_analytics_ustc/images/nation_count.png',dpi=600,bbox_inches="tight")
In [90]:
dict_nation = count_nation.to_dict()
json.dump(dict_nation, open('count_nation.json', 'w'))