简体   繁体   中英

Error in pandas “AttributeError: 'DataFrame' object has no attribute 'round'”

I am building a machine learning model, after normalization, I am trying to round up values but pandas DataFrame throwing an error

 "AttributeError: 'DataFrame' object has no attribute 'round'"

Example Code:

>>> import pandas as pd
>>> df = pd.read_csv("Des_Cor_remove.csv")
>>> df.round(2)

And I'm not able to figure out the exact problem as earlier I have used this method to round up the data frames, Please help.

Update your pandas module to the latest version.


Use :

pip install --upgrade pandas

Next, you can use this function.


Example :

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.random([3, 3]), columns=['A', 'B', 'C'], index=['first', 'second', 'third'])
df.round()

          A    B    C
first   1.0  0.0  0.0
second  1.0  1.0  1.0
third   0.0  1.0  1.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM