在pandas中命名数据帧时遇到问题。有没有办法自动命名和索引更改而不是手动逐行编写?
xl=pd.ExcelFile('Movement of BSE RIK.xlsx',header=0,dtype={'Open Price
(Rs.)':np.float64})
p=xl.sheet_names
df= xl.parse('D-0')
df1= xl.parse('D-1')
df2= xl.parse('D-2')
df3= xl.parse('D-3')
df4= xl.parse('D-4')
df5= xl.parse('D-5')
df6= xl.parse('D-6')
df7= xl.parse('D-7')
df8= xl.parse('D-8')
df9= xl.parse('D-9')
df10= xl.parse('D-10')
df11= xl.parse('D-11')
df12= xl.parse('D-12')
df13= xl.parse('D-13')
df14= xl.parse('D-14')
df.set_index('Security Name',inplace=True)
df1.set_index('Security Name',inplace=True)
df2.set_index('Security Name',inplace=True)
df3.set_index('Security Name',inplace=True)
df4.set_index('Security Name',inplace=True)
df5.set_index('Security Name',inplace=True)
df6.set_index('Security Name',inplace=True)
df7.set_index('Security Name',inplace=True)
df8.set_index('Security Name',inplace=True)
df9.set_index('Security Name',inplace=True)
df10.set_index('Security Name',inplace=True)
df11.set_index('Security Name',inplace=True)
df12.set_index('Security Name',inplace=True)
df13.set_index('Security Name',inplace=True)
df14.set_index('Security Name',inplace=True)
此代码非常冗长,我必须使用这些数据帧名称进一步工作。简而言之,我想最小化这些代码
答案 0 :(得分:2)
我认为您可以使用参数sheetname=None
来创建dict
的{{1}}:
DataFrames
然后您可以选择dfs = pd.read_excel('Movement of BSE RIK.xlsx',
header=0,
dtype={'Open Price (Rs.)':np.float64},
sheetname=None,
index_col='Security Name')
:
DataFrames
file示例:
print (dfs['D-0'])
print (type(dfs['D-0']))
<class 'pandas.core.frame.DataFrame'>
答案 1 :(得分:2)
您可以生成DataFrames字典:
<div class="container">
<div class="logo">
<img src="C:\Users\Ragul\Desktop\my resume html\images.png">
</div>
</div>
.container {
width:100%;
}
.logo img {
float: left;
border: 1px solid black;
}
/* clear float */
.container:after {
content:" ";
display:table;
clear:both;
}