import pandas as pd

shirts = pd.read_csv("shirts.csv")
print("shirts before:")
print(shirts)
print()

# TECHNIQUE #1:
#shirts.loc[shirts['size']=='xxlarge','size'] = 4
#shirts.loc[shirts['size']=='xlarge', 'size'] = 4
#shirts.loc[shirts['size']=='large',  'size'] = 3
#shirts.loc[shirts['size']=='medium', 'size'] = 2
#shirts.loc[shirts['size']=='small',  'size'] = 1
#shirts.loc[shirts['size']=='xsmall', 'size'] = 1

# TECHNIQUE #2:
#shirts['size'].replace('xxlarge', 4, inplace=True)
#shirts['size'].replace('xlarge',  4, inplace=True)
#shirts['size'].replace('large',   3, inplace=True)
#shirts['size'].replace('medium',  2, inplace=True)
#shirts['size'].replace('small',   1, inplace=True)
#shirts['size'].replace('xsmall',  1, inplace=True)

# TECHNIQUE #3:
#shirts['size'] = shirts['size'].apply({'xxlarge':4, 'xlarge':4, 'large':3, 'medium':2, 'small':1, 'xsmall':1}.get)

# TECHNIQUE #4:
shirts['ssize'] = shirts['ssize'].replace(regex='xlarge', value=4)
shirts['ssize'] = shirts['ssize'].replace(regex='large',  value=3)
shirts['ssize'] = shirts['ssize'].replace(regex='medium', value=2)
shirts['ssize'] = shirts['ssize'].replace(regex='small',  value=1)

print("shirts after:")
print(shirts)

