python 获取Excel中指定的行,并转为Dataframe格式,删除空值的行 保存到新文件

import pandas as pd 

df = pd.read_excel('test.xlsx', sheet_name='WBS')
dfItem = df['Item']
dfCommand = df['Command']
dfValue = df['Value']
dict = {'Item':dfItem, 'Command':dfCommand, 'Value':dfValue}

#对Dataframe格式数据进行数据清洗,删除值为空的行
data = pd.DataFrame(dict).dropna(axis=0,how='any')
pd.DataFrame(data).to_excel('new.xlsx')

 

你可能感兴趣的:(python)