import pandas as pd
path1 = \"/home/supertramp/Desktop/100&life_180_data.csv\"
mydf = pd.read_csv(path1)
numcigar = {\"Never\":0 ,\"1-5 Cigarettes/day\" :1,\"10-
Try using this function for all problems of this kind:
def get_series_ids(x):
'''Function returns a pandas series consisting of ids,
corresponding to objects in input pandas series x
Example:
get_series_ids(pd.Series(['a','a','b','b','c']))
returns Series([0,0,1,1,2], dtype=int)'''
values = np.unique(x)
values2nums = dict(zip(values,range(len(values))))
return x.replace(values2nums)