熊猫:csv文件,连接后为什么还有缺失值?

时间:2018-10-25 03:41:00

标签: python-3.x pandas export-to-csv

嗨,任何看到我的问题的人,请提前。

我在“ financial_tag ”列中分别有3个csv文件don't have Missing values,但在contat之后。**

代码在这里:

import pandas as pd

dt1 = pd.read_csv('f:\Sep.csv', encoding='gbk', low_memory=False)
dt2 = pd.read_csv('f:\Aug.csv', encoding='gbk', low_memory=False)
dt3 = pd.read_csv('f:\Jul.csv', encoding='gbk', low_memory=False)

a = dt1.loc[(dt1['financial_tag'] != 157)
        & (dt1['financial_tag'] != 171)
        & (dt1['financial_tag'] != 172)]
b = dt2.loc[(dt2['financial_tag'] != 157)
        & (dt2['financial_tag'] != 171)
        & (dt2['financial_tag'] != 172)]
c = dt3.loc[(dt3['financial_tag'] != 157)
        & (dt3['financial_tag'] != 171)
        & (dt3['financial_tag'] != 172)]

a.to_csv('f:\hahSep.csv', encoding='gbk')
b.to_csv('f:\hahAug.csv', encoding='gbk')
c.to_csv('f:\hahJul.csv', encoding='gbk')

abc = pd.concat([a, b, c])
abc.to_csv('f:\hah.csv', encoding='gbk')

print('done')

hah.csv

  

financial_tag
   N有效971810
        缺少9

hahAug.csv

  

financial_tag
   N有效364144
        缺少0

hahJul.csv

  

financial_tag
   N有效356924
        缺少0

hahSep.csv

  

financial_tag
   N有效250751
        缺少0

0 个答案:

没有答案