我从这里读取我的arff数据帧https://archive.ics.uci.edu/ml/machine-learning-databases/00426/如下所示:
from scipy.io import arff
import pandas as pd
data = arff.loadarff('Autism-Adult-Data.arff')
df = pd.DataFrame(data[0])
df.head()
如何删除它
当我尝试这种方法时,效果并不理想:
from scipy.io import arff
import pandas as pd
data = arff.loadarff('Autism-Adult-Data.arff')
df = pd.DataFrame(data[0].str.decode('utf-8'))
df.head()
它说AttributeError:'numpy.ndarray'对象没有属性'str' 正如您所看到的,Removing b'' from string column in a pandas dataframe中的.str.decode('utf-8')并没有解决问题
这也不管用:
df.index = df.index.str.encode('utf-8')
A您可以看到它的字符串和数字都是字节对象
虽然Shimon分享了答案,但您也可以尝试一下:
相关问题 更多 >
编程相关推荐