Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 数据采集与过滤_Python_Pandas - Fatal编程技术网

Python 数据采集与过滤

Python 数据采集与过滤,python,pandas,Python,Pandas,我有一个数据帧,叫做fechadas: print(fechadas) CNPJ Favorecido 0 9574957000116 ccs construtora eireli 1 73780215000146 d & m empreiteira de projetos e obras l

我有一个数据帧,叫做fechadas:

print(fechadas)

              CNPJ                                         Favorecido
0    9574957000116                             ccs construtora eireli   
1   73780215000146         d & m empreiteira de projetos e obras ltda   
2   21592015000166                        f t r construtora ltda - me   
3                                                                       
4                                                                       
5   20739399000134      four business desenvolvimento e servicos ltda   
6   20739399000134      four business desenvolvimento e servicos ltda   
7   20739399000134      four business desenvolvimento e servicos ltda   
8   20739399000134      four business desenvolvimento e servicos ltda   
9   17483741000173                      comercial tocantins ltda - me   
10                                                                      
11  17483741000173                      comercial tocantins ltda - me   
12                                                                    
我想取出Favorecido为空的行,因此我使用以下代码:

fechadas=fechadas.dropna(subset=["Favorecido"],axis=0)
fechadas=fechadas.loc[((fechadas['Favorecido'] != "") | (fechadas['Favorecido'] != " ")]
fechadas=fechadas.loc[(len(fechadas['Favorecido']) != 0) | (fechadas['Favorecido'] != True)]
但是,当我打印fechadas时,它看起来完全一样:

              CNPJ                                         Favorecido  \
0    9574957000116                             ccs construtora eireli   
1   73780215000146         d & m empreiteira de projetos e obras ltda   
2   21592015000166                        f t r construtora ltda - me   
3                                                                       
4                                                                       
5   20739399000134      four business desenvolvimento e servicos ltda   
6   20739399000134      four business desenvolvimento e servicos ltda   
7   20739399000134      four business desenvolvimento e servicos ltda   
8   20739399000134      four business desenvolvimento e servicos ltda   
9   17483741000173                      comercial tocantins ltda - me   
10                                                                      
11  17483741000173                      comercial tocantins ltda - me   
12                                                                      

我做错什么了吗?

我建议更改第二个条件,以删除可能的更多空格:

fechadas=fechadas[(fechadas['Favorecido'].str.strip() != "")]
如果不工作,请检查问题值的外观:

print (df.loc[[3,4,10,12], 'Favorecido'].tolist())

我建议更改第二个条件,以删除可能的更多空间:

fechadas=fechadas[(fechadas['Favorecido'].str.strip() != "")]
如果不工作,请检查问题值的外观:

print (df.loc[[3,4,10,12], 'Favorecido'].tolist())

我建议将第二个条件改为:
使用=代替=

我建议将第二个条件更改为: 使用=代替=

OP need我想取出Favorecido为空的行,因此我使用以下代码:OP need我想取出Favorecido为空的行,因此我使用以下代码: