text_html_output_1.png
import pandas as pd

df = pd.read_csv('../input/NationalNames.csv')

df['Decade'] = df['Year'].apply(lambda x: x - x % 10)

df_pivot = df.pivot_table(values='Count', index=['Decade', 'Name', 'Gender'], aggfunc='sum')
new_df = pd.DataFrame()
new_df['Decade'] = df_pivot.index.get_level_values('Decade')
new_df['Name'] = df_pivot.index.get_level_values('Name')
new_df['Gender'] = df_pivot.index.get_level_values('Gender')
new_df['Count'] = df_pivot.values

new_df.head()