#import pandas as pd #上面引入了这里就不需要重复引入,如果是独立的文件需要写上这句
def valConditionExc(in_file,out_file):
data_frame = pd.read_excel(in_file, 'january_2015', index_col=None)
data_frame_value_meets_condition = data_frame[data_frame['Sale Amount'].astype(float) > 567.0]
writer = pd.ExcelWriter(out_file)
data_frame_value_meets_condition.to_excel(writer, sheet_name='jan_15_output',index=False)
writer.save()
#行中的值匹配于特定模式
def valMatchPattern(in_file,out_file):
data_frame = pd.read_excel(in_file, 'january_2015', index_col=None)
df_value_matp = data_frame[data_frame['Customer Name'].str.startswith("J")]
writer = pd.ExcelWriter(out_file)
df_value_matp.to_excel(writer, sheet_name='jan_15_output',index=False)
writer.save()
print(df_value_matp)
#选择满足一定条件的特定列数据
def selectColByIndex(in_file,out_file):
data_frame = pd.read_excel(input_file, 'january_2015', index_col=None)
df_col_by_index = data_frame.iloc[:, [1, 4]]
writer = pd.ExcelWriter(output_file)
df_col_by_index.to_excel(writer, sheet_name='jan_15_output',index=False)
writer.save()
in_f='sales_2015.xlsx'
valConditionExc(in_f,'save_sales_2015_2.xlsx')
valMatchPattern(in_f,'save_sales_2015_3.xlsx')