I am trying to perform the following task: I want to create 10 dataframes whose lon
values are less than/greater than the numbers given in split
. These lon
are different each time but connected, for example:
dfre0 = dfres[(dfres["lon"] > split[0]) & (dfres["lon"] <= split[1])]
dfre1 = dfres[(dfres["lon"] > split[1]) & (dfres["lon"] <= split[2])]
Where the vector split
is:
>>> split = np.linspace(-180.0, 180.0, num=10)
array([-180., -140., -100., -60., -20., 20., 60., 100., 140., 180.])
The line with the for-loop is something like:
for i in range(len(split)):
dfres[(dfres["lon"] > split[i]) & (dfres["lon"] <= split[i+1])]
But how I change the name each time?
Instead of doing it by hand each time, is there any way to do it inside a loop?