i have data csv
word,centroid
she,1
great,0
good,3
mother,2
father,2
After,4
before,4
.....
I just want to see the centroid
my code is:
df = pd.read_csv('data/hasil_cluster.csv',encoding = "ISO-8859-1")
print(df['centroid'])
and error:
KeyError: 'centroid'
There is ;
after centroid
:
print (df.columns.tolist())
['word', 'centroid;']
You can remove all ;
before and after column names:
df.columns = df.columns.str.strip(';')
Or use rename
:
df = df.rename(columns={'centroid;':'centroid'})
Or reassign columns names:
df.columns = ['word', 'centroid']
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.