代码语言:javascript复制
# Edit By Python3.6
import os,csv,pandas as pd
path = 'C:\Users\Desktop\NBA'
filepath = os.chdir(path)
with open('A.csv') as csvfile:
reader = csv.reader(csvfile)
rows= [row for row in reader]
column = [row[1] for row in reader]
print(column)
print(rows)
print('...............')
data=pd.read_csv('A.csv')
print(data)
print('.......')
print(list(data.get('Name')))
print(type(data.get('Name')))
print('....................Df')
dataNanColumn=data.dropna(axis=1,how='any') # 只要出现nan,则删除该列,若all,则该列全为nan,才删除,此删除不会改变源文件数据
data.dropna()
dataNanRow=data.dropna(axis=0,how='any')
# drop all rows that have any NaN values
print('No Row nan')
print(dataNanRow)
print('No Column nan')
print(dataNanColumn)
获取某列,某行,去除NAN行,NAN列...