Python Pandas dataframe未定位列值,给出NaN
现在,我正在分离特征Python Pandas dataframe未定位列值,给出NaN,python,python-3.x,pandas,dataframe,data-analysis,Python,Python 3.x,Pandas,Dataframe,Data Analysis,现在,我正在分离特征 import pandas as pd df = pd.read_csv("ABC.txt", names=['timestamp', 'value 1', 'value 2', 'value 3', 'value 4', 'label']) print(df) //This prints values correctly 打印x features = ['value 1', 'value 2', 'value 3', 'value 4'] x = df.lo
import pandas as pd
df = pd.read_csv("ABC.txt",
names=['timestamp', 'value 1', 'value 2', 'value 3', 'value 4', 'label'])
print(df) //This prints values correctly
打印x
features = ['value 1', 'value 2', 'value 3', 'value 4']
x = df.loc[:, features].values
print(x) // This prints NaN values
这个代码有什么问题?谢谢。请提供一个。您的代码对我有效,您的.txt文件中有什么?我有1503510962527.000000-67.000000-41.000000-10.000000-3.000000-6.000000-5.000000这样的值,实际上它给出了“ValueError:Input包含NaN、无穷大或对于数据类型('float64')太大的值。”
[[nan nan nan ... nan nan nan]
[nan nan nan ... nan nan nan]
[nan nan nan ... nan nan nan]
...
[nan nan nan ... nan nan nan]
[nan nan nan ... nan nan nan]