You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a normal DataFrame I would do this to normalize the stock price:
# First Index
first_index = df.index[0]
# Normalize Price
df["Price_normalized"] = df["Price"] / df.loc[first_index, 'Price']
print(df)
However, in my case I am filtering the DataFrame with a DateRangeSlider. Because of this the first_index, on which i normalize, changes. It should always be the first price of the filtered DataFrame "rdf". The basic pandas method does not work and I get an error.
rdf=pn.rx(df)
# First Index
first_index = rdf.index[0]
# Normalize Price
rdf["Price_normalized"] = rdf["Price"] / rdf.loc[first_index, 'Price']
I am getting the TypeError:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[33], line 7
4 first_index = rdf.index[0]
6 # Normalize Price
----> 7 rdf["Price_normalized"] = rdf["Price"] / rdf.loc[first_index, 'Price']
TypeError: 'rx' object does not support item assignment
The text was updated successfully, but these errors were encountered:
Originally from
https://discourse.holoviz.org/t/normalizing-stock-market-data-with-reactive-dataframe/7515
I am trying to normalize stock market data of an reactive DataFrame. I am getting an error and need a bit of help.
This is the minimal, reproducible example:
In a normal DataFrame I would do this to normalize the stock price:
However, in my case I am filtering the DataFrame with a DateRangeSlider. Because of this the first_index, on which i normalize, changes. It should always be the first price of the filtered DataFrame "rdf". The basic pandas method does not work and I get an error.
I am getting the TypeError:
The text was updated successfully, but these errors were encountered: