Category : data-science

there are a lot more than 3 products(A,B,C…) here is just an example import pandas as pd df = pd.DataFrame(data=[[‘A’, ‘2021-01-06 10:25:21’], [‘A’, ‘2020-11-04 08:48:23’], [‘B’, ‘2020-10-26 17:04:34’], [‘C’, ‘2020-08-05 17:06:09’], [‘A’, ‘2021-04-15 13:20:50’], [‘B’, ‘2021-04-05 18:20:29’]], [‘A’, ‘2021-04-15 13:20:50’], [‘C’, ‘2021-01-05 14:05:09’], columns=[‘product’, ‘purchased_at’]) df | product | purchased_at | | ——– | ——————–| ..

Read more

fuel_type= {‘fuel_Petrol’:1,’fuel_Diesel’:2,’fuel_Electric’:3,’fuel_LPG’:4,’fuel_CNG’:5} df[‘fueltype’]= df[‘fuel_Petrol’,’fuel_Diesel’,’fuel_Electric’,’fuel_LPG’,’fuel_CNG’].apply(lamda x: fuel_type(x)) I am getting this error: File "", line 2 df[‘fueltype’]= df[‘fuel_Petrol’,’fuel_Diesel’,’fuel_Electric’,’fuel_LPG’,’fuel_CNG’].apply(lamda x: fuel_type(x)) ^ SyntaxError: invalid syntax Source: Python..

Read more