请可以有人帮助.我想到导出%更改值从值(粗体)到excel.但我得到消息
KeyError:“未找到'columns'中指定的所有名称”
import pandas as pd
# import openpyxl module
#import openpyxl
import numpy as np
# Give the location of the file
path = 'C:/Users/a1b.xlsx'
df= pd.read_excel(path, sheet_name='Sheet1', usecols=['Date','name', 'myname', 'fx'])
ds= pd.read_excel(path, sheet_name='Sheet1', usecols=['Date'])
df2= pd.read_excel(path, sheet_name='Sheet1', usecols=['Date','name1', 'myname1', 'fx1'])
#print (df2)
df3= df.copy()
df[['name','myname','fx']] = df[['name','myname','fx']].pct_change(periods = 5)
**a= df2[np.array(df)> np.array(df2)]**
print (a)
a.to_excel(''C:/Users/a1b.xlsx', sheet_name='Sheet3',startcol=2,index=False,columns= ['Date','name', 'myname', 'fx'])
我期望的值来自a= df2[np.array(df)〉np.array(df2)]
1条答案
按热度按时间rt4zxlrg1#
我正在寻找的是只返回行whwere数组(df)〉数组(df2)然而在excel中我看到每一个单行返回.有一种方法pls a= df2[np.数组(df)〉np.数组(df2)]