在CSV文件中打印行值

时间:2019-05-29 06:50:17

标签: python-3.x pandas csv dataframe outliers

读取csv文件,查找特定cpoumn的离群值,并为所得的oulier打印行

11957163    10028   20270   76.59   3.563   711.4643076 733.323696  709         31-01-2019 23:59    31-01-2019 23:59    EQUAL
11957164    10009   20075   42      12609.29675 12609.29675             31-01-2019 23:59    31-01-2019 23:59    
11957161    10020   20107   77      43257.98004 43257.98004             31-01-2019 23:59    31-01-2019 23:59    
11957162    10025   20147   9.17    0.866   184.1165368 89.38818    79  0   0   31-01-2019 23:59    31-01-2019 23:59    NONE
11957160    10018   20156   91.37   4.154   927.3626504 907.80183   832         31-01-2019 23:59    31-01-2019 23:59    EQUAL
11957158    10013   20226   85.53   3.921   876.1176555 871.84152   799         31-01-2019 23:59    31-01-2019 23:59    EQUAL
11957159    10024   20138   34.21   1.868   331.2117327 67  321 0   0   31-01-2019 23:59    31-01-2019 23:59    NONE
11957154    10010   20081   65.59   3.123   491.7192058 503.282688  507         31-01-2019 23:58    31-01-2019 23:58    EQUAL
11957153    10014   20236   12.42   0.996   117.0957776 118.668 105 0   0   31-01-2019 23:58    31-01-2019 23:58    NONE
11957155    10027   20262   66.66   3.166   658.696863  665.617616  323         31-01-2019 23:58    31-01-2019 23:58    NONE
11957157    10025   20144   93.69   4.247   880.139813  877.48496   813         31-01-2019 23:58    31-01-2019 23:59    EQUAL
11957151    10026   20252   72.57   3.402   745.4112954 698.978192  806         31-01-2019 23:58    31-01-2019 23:58    EQUAL
11957150    10020   20109   75.3        30263.8071  30263.8071              31-01-2019 23:58    31-01-2019 23:58    
11957152    10015   20244   59.47   2.878   636.2596239 615.700178  558         31-01-2019 23:58    31-01-2019 23:58    LOW
11957146    10013   20219   92.51   4.2 953.303206  937.98276   853         31-01-2019 23:58    31-01-2019 23:58    EQUAL
11957148    10013   20225   91.57   4.162   911.8152283 923.659072  849         31-01-2019 23:58    31-01-2019 23:58    EQUAL

csv文件

import numpy as np
import pandas as pd
from pandas import loc
import csv

with open('C:/Users/Dell/Desktop/levelSensorDataJan1/levelSensorDataJan.csv', 'r')as f:
          data = csv.reader(f)
          for row in data:
              print (row[2])
              data.loc[1]
              print (row[1])
          # data = pandas.DataFrame(numpy.random.randn(5,3),columns=list('ABC'))
          #print([x for x in csv.reader(f)][1])
data['id'] = [random.randint(0,12) for x in range(data.shape[0])]

打印第4列中的异常值行

0 个答案:

没有答案