Convert the indices to slices or integers :" TypeError: list indices must be integers or slices, not str"

I have created lists from my data frame (df1)and I am trying to subtract the values(high tide and low tide) and plot them but keep getting stuck with the maximums. Here is my code:

import pandas as pd
import numpy as np
df1 = pd.read_csv (r'C:\Intel\Solinst-cleaned up\yellow.csv', skiprows = 13, encoding= 'unicode_escape', parse_dates=[['Date', 'Time']])

# Normal condition (From Jan 20th to Feb 11th)
start = 50     # First row to consider
stop = 3200     # Last row to consider
interval = 75  # The desired chunk size
x=df1['Date_Time'][50:125]

y1=[]
for i in range(start, stop, interval):
    y1.append(df1["Mlevel"][i:(i + interval)])
    
#y1 = y1.reset_index(drop=True)

hightide=[]   
for i in range(start, stop, interval):
    hightide=max(y1[1].loc[y1['Mlevel'][i:(i + interval)]])

And I get :

File "C:/Users/mr179/Desktop/Research/PhD/codes/test.py", line 42, in hightide=max(y1[1].loc[y1['Mlevel'][i:(i + interval)]])

TypeError: list indices must be integers or slices, not str



from Recent Questions - Stack Overflow https://ift.tt/3xwsUwx
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations