I have the dataframe df.info()
:
M 5899 non-null float64
I need to get rid of the .0
that the column M has.
df['M'].value_counts()
4354.0 4382
454.0 98
234324.0 98
I have tried df['M'].astype('int64')
which gives me the same results as above.
What can I do to get rid of the decimal zero?
Try to change option pandas for display if you don't want to change type of the column
import pandas as pd
data = {
'M': [5899.0, 4354.0, 454.0, 234324.0],
}
df = pd.DataFrame(data)
pd.set_option('display.precision', 0)
df['M'].value_counts()