In [12]:
import os
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
source_path = 'D:\Python_my\Python_Netology_homework\data_names'
source_dir_path = os.path.normpath(os.path.abspath(source_path))
source_file = os.path.normpath(os.path.join(source_dir_path, 'yob{}.txt'.format(1950)))
year_data = pd.read_csv(source_file, names=['Name', 'Gender', 'Count'])
year_data = year_data.drop(['Gender'], axis=1)
top_10 = year_data[(year_data.Name.str.startswith('R'))].head(10)
top_10
Out[12]:
In [2]:
top_10 = year_data[(year_data.Count > 3000) & (year_data.Name.str.startswith('R'))].head(10)
top_10
Out[2]:
In [3]:
top_10 = year_data[(year_data.Count > 3000) & (year_data.Name.str.startswith('R'))].sort_values('Count', ascending=False).head(10)
top_10
Out[3]:
In [13]:
r_name = year_data[(year_data.Name.str.startswith('R'))]
top_10 = r_name.groupby('Name').sum().sort_values('Count', ascending=False).head(10)
top_10
Out[13]:
In [14]:
top_10.plot.pie(y='Count')
Out[14]:
In [6]:
import matplotlib.pyplot as plt
In [8]:
top_10.plot.pie(y='Count')
Out[8]:
In [10]:
%matplotlib inline
In [11]:
top_10.plot.pie(y='Count')
Out[11]:
In [ ]: