Home > database >  Python not able to process the data from Excel file
Python not able to process the data from Excel file

Time:10-05

My problem is that when I run my code it does not execute.

My code reads a excel file and takes the max value from the excel and puts in a array and repeats it 100 times. I used while loop to do it, but the only loads the excel and gets stuck for a long time.

The code is as follows:

df = pd.read_excel(r'my_excel.xlsx', sheet_name='record')
print(df)
# Column Describe 
df.columns = [  "DataPoint",
    "Cycle Index",
    "Step Index",
    "Step Type",
    "Time",
    "Cumulative Time".....  ] 
reg_charge = df.loc[df["Step Index"] ==2]
i=2
last=100
x =[]
y =[]
while i < 101:
 yy = reg_charge["Capacity(Ah)"][reg_charge["Cycle Index"] == i]
 xx = reg_charge["Cycle Index"][reg_charge["Cycle Index"] == i]
 xmax=np.max(xx)
 ymax=np.max(yy)
x.append(xmax)
y.append(ymax)
i  = 1

Any idea how i can make it faster. The Excel is pretty big with 120k rows.

CodePudding user response:

enter image description here

You are incrementing "i" outside of the loop which is why it is going into infinity loop. You may need to increment this within the while loop.

  • Related