Jan-21-2022, 06:24 PM
Hi
I´m using the following code to fill a dataframe with values that are stored in a .nc file
This code is quite slow. The speed can be improved with list comprehensions? If the answer is yes, can you give me an example?
Thank you very much
I´m using the following code to fill a dataframe with values that are stored in a .nc file
This code is quite slow. The speed can be improved with list comprehensions? If the answer is yes, can you give me an example?
Thank you very much
data_range = pd.date_range(start = '2000-01-01', end = '2011-01-01', freq='H')
df1 = pd.DataFrame(0, columns = ['t2m'], index = data_range)
df = df1.iloc[:-1 , :]
dt = np.arange(0, data.variables['time'].size)
temperature = data.variables['t2m']
for time_index in dt:
df.iloc[time_index] = temperature[time_index, min_index_lat,min_index_lon]-273.15
print (time_index)
