<jupyter_start><jupyter_text>In this step, I convert Pandas.Series file to Pandas.Dataframe file, because I don't know how to use groupby function to make plot directly. Luckily, this method works.<jupyter_code>data3d = data3d.unstack()
data3d

def on_selected(change):
    if len(change['owner'].selected) == 1:
        #print(change['owner'].selected[0])
        i, j = change['owner'].selected[0]
        column=data3d.columns.tolist()[j] # To get the column name of selected data
        row = data3d.index.tolist()[i] # To get the row name of selected data
        region_mask = ((data['Congress Dist']==row) & ((data['Agency Name'])==column))
        data_selected = data[region_mask]
        data2 = data_selected.groupby('Year Acquired')['Square Footage'].sum()
        dict_data2 = {'Year Acquired':data2.index,'Square Footage':data2.values}
        data_selected1 = pd.DataFrame(dict_data2)
        v = data3d.iloc[i,j]
        line_plot.x = data_selected1['Year Acquired']
        line_plot.y = data_selected1['Square Footage']
        if str(v) != 'nan':
            mySelectedLabel.value = 'Data Value ='+str(v)
        else:
            mySelectedLabel.value = "No data here" #This is how I deal with NaN's
data_selected = data.head(100)
data2 = data_selected.groupby('Year Acquired')['Square Footage'].sum()
dict_data2 = {'Year Acquired':data2.index,'Square Footage':data2.values}
data_selected1 = pd.DataFrame(dict_data2)
print((data_selected1))<jupyter_output>Year Acquired  Square Footage
0            1970           10000
1            1972           11000
2            1975             144
3            1976             778
4            1980             769
5            1981             216
6            1985             700
7            1987             729
8            1988           10584
9            1993           38276
10           1994            2000
11           1995             270
12           1996            3189
13           1997             884
14           1998            1163
15           1999              96
16           2000          120451
17           2001          337300
18           2002          214700
19           2004             720
20           2006             240<jupyter_text>Like what I did for the heatmap, I convert series to dataframe. The number in 'Square Footage' column is the total square footage of that year<jupyter_code>mySelectedLabel = ipywidgets.Label()
col_sc = bqplot.ColorScale(scheme='Blues')
data_selected = data.head(100)
data2 = data_selected.groupby('Year Acquired')['Square Footage'].sum()


#Scales
x_sc = bqplot.OrdinalScale()
y_sc = bqplot.OrdinalScale()

#Axis
x_ax = bqplot.Axis(scale=x_sc,label='Agency Name')
y_ax = bqplot.Axis(scale=y_sc,orientation='vertical',label='Congressional District')
c_ax = bqplot.ColorAxis(scale=col_sc, orientation='vertical',side='right')

#Mark
heat_map = bqplot.GridHeatMap(color=data3d,row=data3d.index.tolist(), column=data3d.columns.tolist(),
                              scales = {'color':col_sc,'row':y_sc,'column':x_sc},
                              interactions={'click':'select'},
                              anchor_style={'fill':'red'},
                              selected_style={'opacity':1.0},
                              unselected_style={'opacity':0.8})

#Interaction
heat_map.observe(on_selected,'selected')

##2
#x_scl = bqplot.DateScale(min=dt.datetime(1950,1,1),max=dt.datetime(2021,1,1))
x_scl = bqplot.LinearScale(min=1950,max=2021)
y_scl = bqplot.LinearScale()

ax_xcl = bqplot.Axis(label='Year Acquired',scale=x_scl)
ax_ycl = bqplot.Axis(label='Total Footage Acquired',scale=y_scl,orientation='vertical',side='left')

line_plot = bqplot.Lines(x=data_selected1['Year Acquired'],
                               y= data_selected1['Square Footage'],
                              scales={'x':x_scl,'y':y_scl})
line_plot_figure = bqplot.Figure(marks=[line_plot],axes=[ax_xcl,ax_ycl])



fig = bqplot.Figure(marks=[heat_map],axes=[c_ax,y_ax,x_ax])
# to make the dashboard prettier
fig.layout.min_width='500px'
line_plot_figure.layout.min_width='500px'
figures = ipywidgets.HBox([fig,line_plot_figure])
myDashboard = ipywidgets.VBox([mySelectedLabel,figures])

myDashboard<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11540273198304286, 'fraction_numerical': 0.06241168158266604, 'mean_word_length': 2.5303408146300916, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '352213', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1333, 'n_words': 278, 'path': 'Chen-Tianli-Homework6.ipynb', 'repo_name': 'tianlic2/tianlic2.github.io', 'size': '4246'}