Pandas data frame. Change float format. Keep type “float”
问题 I'm trying to change a format of pd data frame column without changing the type of data. Here is what I have: df = pd.DataFrame({'Age': [24.0, 32.0}]) I'd like to represent Age in 24 32 type or 24.00 32.00 and keep them as floats. Here is what I can do: df['Age'].map('{:,.2f}'.format) But this line changes the type of data to object. I was also trying to apply: ` df = df.style.format({'Age': '{:,.2f}'.format})` but there is something wrong in it. Please help to figure out the right way. 回答1: