0

I have a data frame that is grouped by two columns: "year" and "neighborhood" . I want to be able to sale prices per sq foot and gross rent as line charts and be able to toggle between neighborhoods. At the moment the widget is rendered but as I toggle between neighborhoods the data stays the same. Any thoughts on why this might not be working?

# Group by year and neighborhood and then create a new dataframe of the mean values

prices_by_year_by_neighborhood = sfo_data_df.groupby(by=['year','neighborhood']).mean()

# Review the DataFrame
prices_by_year_by_neighborhood.head()

[screenshot1](https://i.stack.imgur.com/FAths.png)

# Filter out the housing_units
prices_by_year_by_neighborhood = prices_by_year_by_neighborhood.drop(columns=['housing_units'])

# Review the first and last five rows of the DataFrame
display(prices_by_year_by_neighborhood.head())
display(prices_by_year_by_neighborhood.tail())


# Use hvplot to create an interactive line plot of the average price per square foot
prices_by_year_by_neighborhood.hvplot.line(
    x="year",
    y=["sale_price_sqr_foot", "gross_rent"],
    groupby="neighborhood",
    title="Price per square foot and average gross rent 2010 to 2016 in SF per Neighborhood"
)

screenshot2

screenshot3

I have tried to make sure the naming of the columns is correct and also double checked the parameters for the hvplot line graph.

epR8GaYuh
  • 311
  • 9
  • 21

1 Answers1

0

I had the same issue. I was able to resolve this by installing jupyter_bokeh and adding this code to my notebook.

add code to your notebook:

import panel as pn
pn.extension(comms='vscode')

install:

pip install jupyter_bokeh

see: https://github.com/bokeh/jupyter_bokeh/issues/131

mosc9575
  • 5,618
  • 2
  • 9
  • 32