I was trying to multiply a column in pandas df but i didnt get the expected results: for exemple i have a value which is 22 and i want to convert it to 22000 ...
i tried both these codes and both gave me same incorrect value
k['prix_millions'] = k['prix'].apply(lambda x: x * 1000 if int(x) == x and len(str(x)) == 2 else x)
also this:
def to_md(x):
if len(str(x)) == 2:
return x * 1000
else:
return x
# create a new column called prix_millions
k['prix_millions'] = k['prix'].apply(to_md)
i want to multiply the values in 1000