![](/img/trans.png)
[英]TypeError: expected string or bytes-like object in lemmatization nltk
[英]“TypeError: expected string or bytes-like object” while reading csv file in python with nltk
我猜你的數據集中有漂浮值。
您需要將這些浮點值轉換為字符串值。
“pandas.DataFrame.iloc”是純粹基於整數位置的索引,用於按位置選擇,.iloc []主要是基於整數位置(從軸的0到長度-1),但也可以與布爾數組一起使用。
例如 ,
import pandas as pd
mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
{'a': 100, 'b': 200, 'c': 300, 'd': 400},
{'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]
df = pd.DataFrame(mydict)
print(df.iloc[0])
'''
Output:
a 1
b 2
c 3
d 4
'''
df.iloc[[0]]
'''
Output
a b c d
0 1 2 3 4
'''
df.iloc[[0, 1]]
'''
Output
a b c d
0 1 2 3 4
1 100 200 300 400
'''
df.iloc[:3]
'''
Output
a b c d
0 1 2 3 4
1 100 200 300 400
2 1000 2000 3000 4000
'''
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.