简体   繁体   English

查询熊猫Dataframe中的错误

[英]Query errors in a panda Dataframe

I am facing an issue with my code using queries on simple pandas DataFrame, I am sure I am missing a tiny detail. 我在使用简单的pandas DataFrame上的查询时遇到了我的代码问题,我确信我错过了一个小细节。 Can you guys help me with this? 你能帮助我吗? 在此输入图像描述

I don't understand why I've only NAN values. 我不明白为什么我只有NAN值。

You can change [['date']] to [date] for select Series instead one column DataFrame . 您可以将[['date']]更改为[date]以选择Series而不是一列DataFrame

Sample : 样品

df = pd.DataFrame({'A':[1,2,3]})

print (df['A'])
0    1
1    2
2    3
Name: A, dtype: int64

print (df[['A']])
   A
0  1
1  2
2  3

print (df[df['A'] == 1])
   A
0  1

print (df[df[['A']] == 1])
     A
0  1.0
1  NaN
2  NaN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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