<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Tidy Data
Thsis notebbok is designed to explore Hadley Wickman article about tidy data using pandas
The datasets are available on github 
Step1:  Original TB dataset. Corresponding to each ‘m’ column for males, there is also an ‘f’ column
for females, f1524, f2534 and so on. These are not shown to conserve space. Note the mixture of 0s
and missing values. This is due to the data collection process and the distinction is important for
this dataset.
Step2:  Create sex and age columns from variable 'column'
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
# tuberculosis (TB) dataset
path_tb = '/Users/ericfourrier/Documents/ProjetR/tidy-data/data/tb.csv'
df_tb = pd.read_csv(path_tb)
df_tb.head(20)
Explanation: Tidy Data
Thsis notebbok is designed to explore Hadley Wickman article about tidy data using pandas
The datasets are available on github : https://github.com/hadley/tidy-data/blob/master/data/
Import Packages
End of explanation
# clean column names 
df_tb = df_tb.rename(columns={'iso2':'country'}) # rename iso2 in country
df_tb = df_tb.drop(['new_sp'],axis = 1)
df_tb.columns = [c.replace('new_sp_','') for c in df_tb.columns] # remove new_sp_
df_tb.head()
df_tb_wide = pd.melt(df_tb,id_vars = ['country','year'])
df_tb_wide = df_tb_wide.rename(columns={'variable':'column','value':'cases'})
df_tb_wide
Explanation: Original TB dataset. Corresponding to each ‘m’ column for males, there is also an ‘f’ column
for females, f1524, f2534 and so on. These are not shown to conserve space. Note the mixture of 0s
and missing values. This is due to the data collection process and the distinction is important for
this dataset.
End of explanation
# create sex:
ages = {"04" : "0-4", "514" : "5-14", "014" : "0-14",
        "1524" : "15-24","2534" : "25-34", "3544" : "35-44",
        "4554" : "45-54", "5564" : "55-64", "65": "65+", "u" : np.nan}
# Create genre and age from the mixed type column
df_tb_wide['age']=df_tb_wide['column'].str[1:]
df_tb_wide['genre']=df_tb_wide['column'].str[0]
df_tb_wide = df_tb_wide.drop('column', axis=1)
# change category 
df_tb_wide['age'] = df_tb_wide['age'].map(lambda x: ages[x])
# clean dataset 
df_tb_wide
Explanation: Create sex and age columns from variable 'column'
End of explanation
<END_TASK>