@jnava in general you should not replace entire ColumnDataSource
objects. You should always prefer to update existing ColumnDataSource
objects, by assignng to (or modifying) their .data
property. The ColumnDataSource
is a very heavyweight object, and many things have to be torn down/set up to replace them. They are very optimized to transmit data efficiently when their .data
property is updated, though. which is why you should always update data in that way. All of the examples in the repo, docs, or other sites demonstrate doing things this way.
@Bryan ,
Yes, that was my last suggestion in my latest post.
@jnava Sorry, I misread your post. I thought you were suggesting changing
hist_data_xx.source = hist_data_A.filt_df()
to
hist_data_xx.source = hist_data_xx.filt_df()
@VITTAL_S_S Maybe the best example for you to refer to is the sliders one. That updates a plots data based on four sliders. Your update will be different but the overall structure will be be nearly identical.
def filt_df(self): df_temp = self.original_df.copy() df_temp.loc[df_temp['A'] >=self.A_lwr, 'A'] = np.nan df_temp.loc[df_temp['A'] <=self.A_upr, 'A'] = np.nan df_temp.loc[df_temp['B'] >=self.B_lwr, 'B'] = np.nan # ... plus all other filters... self.source.data = create_hist_data(df_temp)
will this work the same as
def filt_df(self): filt = (pd.DataFrame(self.original_df[(self.original_df.A >=self.A_lwr) & (self.original_df.A <= self.A_upr) & (self.original_df.B >= self.B_lwr) & (self.original_df.B <= self.B_upr)])) print(f'{self.A_lwr} {self.A_upr} {self.B_lwr} {self.B_upr}') filt.shape return ColumnDataSource(self.create_hist_data(filt))
are all the filters simultaneously applied to the data frame??
i donât see any thing here doing the âandâ function, I.e applied all the filtering conditions simultaneously
@VITTAL_S_S
No, they wonât work the same. And yes, all âfiltersâ would be applied simultaneously. Did you even tried implementing the snippet (BTW I made a slight edit)? At this point this is not a bokeh related thread, Iâm sure you have all the pointers and resources needed to make your code work. Try consulting @Bryan suggested links, and build your code one step at a time. If youâre not using Spyder, Jupyter, or similar environments I highly suggest you do.
Yeah I tried Implementing the code
it updates the graphs
but i am trying with a small set of data to understand the variation
i am not able to validate if my program is working as intended
and thats the reason i got this doubt