python--pandas-数据可视化
画线;
df.loc['Algeria'].plot(kind='line', label='Algeria') #取出 Algeria 这一行的数据
plt.legend(loc='upper left')
df.T[['Albania', 'Algeria', 'Argentina']].plot(kind='line')
直方图
count, bin_edges = np.histogram(df_can['2013'])
#将数据分成等间距的10个区间,count表示对应区间内有多个数据,bin_edges则是划分的区间,结果如下图
df_can['2013'].plot(kind='hist', figsize=(8, 5), xticks=bin_edges)
plt.title('Histogram of Immigration from 195 countries in 2013') # add a title to the histogram
plt.ylabel('Number of Countries') # add y-label
plt.xlabel('Number of Immigrants') # add x-label
plt.show()
df_t = df_can.loc[['Denmark', 'Norway', 'Sweden'], years].transpose()
df_t.head()
df_t.plot(kind='hist', figsize=(10, 6))
plt