pandas
6
Excel
Let me give you an example. Suppose you have imported data from excel and are DataFrame objects.
you can use the DataFrame.loc object to solve (note the difference from the DataFrame.iloc object)
>>> index=[4, 5, 6, 7, 8] -sharp
>>> columns=[120, 140, 160, 180] -sharp
>>> a = pd.DataFrame(index=index, columns=columns, data=np.random.randn(5, 4)) -sharp data
>>> a
120 140 160 180
4 -1.893583 -1.877188 1.531316 1.468032
5 -0.051771 -0.752350 0.771171 -0.662293
6 -0.252470 -0.084280 0.357515 -0.832810
7 0.112660 -0.559447 0.573227 0.385083
8 1.086797 -1.722506 1.963318 1.362636
>>> -sharp 8, 120
>>> d = input(':')
:8
>>> g = input(':')
:120
>>> a.loc[d, g]
1.0867967045350686
finally got it
import pandas as pd
import numpy as np
df=open('C:/Users/xxxxxxx/.xlsx','rb') -sharp'rb'
df=pd.read_excel(df)
-sharpprint(df.head())
dt=open('C:/Users/xxxxxxx/new_file.csv','rb') -sharp
dt=pd.read_csv(dt)
prs=lambda x:120 if x<140 else (140 if x<160 else (160 if x<180 else 180))
age=lambda x:40 if x<50 else (50 if x<60 else (60 if x<70 else 70))
dgc=lambda x:4 if x<5 else (5 if x<6 else (6 if x<7 else (7 if x<8 else 8)))
ndt = pd.DataFrame() -sharpdataframe
for i in range(1,len(dt)): -sharp
fx=df[(df['']==dt.iloc[i,:][1])&(df['']==age(dt.iloc[i,:][2]))&(df['']==dt.iloc[i,:][9])&(df['']==dt.iloc[i,:][10])&(df['']==dgc(dt.iloc[i,:][17]))]
rsk=fx[prs(dt.iloc[i,:][22])]
v=dt.iloc[i,:].copy() -sharp.copy()
for x in rsk:
v['']=x
ndt=ndt.append(v) -sharp
print(':%.2f %%' %(i/len(dt)*100))
ndt.to_csv('file.csv',encoding='utf_8_sig') -sharp