Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas
- df = pandas.read_csv('Life_expectancy_at_birth_male_years.csv', skiprows=4, index_col=[0,1,2,3])
- df.fillna(0,inplace=True)
- df.drop(df.columns[len(df.columns)-1], axis=1, inplace=True)
- modes = []
- medians = []
- stds = []
- for buf_index, buf_value in df.iterrows():
- modes.append(buf_value.mean())
- medians.append(buf_value.median())
- stds.append(buf_value.std())
- df['mode'] = modes
- df['median'] = medians
- df['std'] = stds
- df.to_csv('out.csv')
- print('done')
Add Comment
Please, Sign In to add comment