When I'm changing the values of a data frame, the values don't appear with decimals but full numbers.
Why does this happen?
df = pd.DataFrame()
df['Values'] = range(10,15)
lst = [1.11, 2.22 ,3.33,4.44,5.55]
for x in range(0,5):
df['Values'][x] = lst[x]
print(test)
CodePudding user response:
Do this after df['Values'] = range(10,15)
:
df['Values'] = pd.to_numeric(df["Values"], downcast="float")
CodePudding user response:
This work out for me! Thanks for the help
test = pd.DataFrame()
test['Values'] = range(10,15)
test['Values'] = test['Values'].astype(float)
lst = [1.11, 2.22 ,3.33,4.44,5.55]
for x in range(0,5):
test['Values'][x] = float(lst[x])
test