I have a dataframe like this:
df = pd.DataFrame({"ID":[1, 1],
"CLASS":["A","B"],
"TOP":[12.4, 29.1],
"BOT":[29.1, 32.8]})
I would like to create a new dataframe, but with a specific range of samples (for example, 5) between my TOP and BOT values.
I know I can create a range with 5 samples with np.linspace, but how can I put this range like two new series alternating TOP and BOT?
range_A = np.linspace(df["TOP"][df["CLASS"] == "A"].min(), df["BOT"][df["CLASS"] == "A"].min(), 5)
range_A
Out[36]: array([12.4 , 16.575, 20.75 , 24.925, 29.1 ])
range_B = np.linspace(df["TOP"][df["CLASS"] == "B"].min(), df["BOT"][df["CLASS"] == "B"].min(), 5)
range_B
Out[37]: array([29.1 , 30.025, 30.95 , 31.875, 32.8 ])
The new dataframe doesn't need to have 5 samples for each CLASS. So it should be like this:
Anyone could help me?
