<jupyter_start><jupyter_text>Prep<jupyter_code>import pandas as pd
import numpy as np
import plotly.express as px
tree = pd.read_csv('../tree-census-2015.csv')
tree.shape
tree.columns
# tree.loc[:, 'genus'] = tree.spc_latin.str.extract('^([^ ]*)')
tree.loc[:, 'count'] = 1<jupyter_output><empty_output><jupyter_text>Question 1<jupyter_code>tree['health'].value_counts(dropna = False)
tree.head()
tree['borough'].value_counts(dropna = False)
tree_q1 = tree[['borough', 'spc_common', 'health', 'count', 'steward']]
tree.head()
tree_q1.head()
tree_q1.columns
tree_q1.index
agg_q1 = tree_q1.groupby(['borough', 'spc_common', 'health', 'steward']).sum().reset_index()
agg_q1
agg_q1.shape
agg_q1.to_csv('agg.csv')
tree['steward'].value_counts()
tree['spc_common'].value_counts().shape
tree.iloc[1]
(tree['spc_common'].isna() | tree['health'].isna() | tree['borough'].isna() | tree['steward'].isna()).sum()
tree['count'].sum()
tree.shape
agg_q1.spc_common.to_dict()
c2 = ['spc_common', 'spc_latin']
spc_map = tree[c2].groupby(c2).count().reset_index()
spc_map.to_clipboard()
def series2dropdown(s):
    l = list()
    for v in s.unique():
        l.append({'label': v, 'value': v})
    return(l)
series2dropdown(agg_q1.borough)
series2dropdown(agg_q1.health)
df = pd.read_csv('../agg-post.csv')
df.Health = pd.Categorical(df.Health, categories = ['Poor', 'Fair', 'Good'])
dff = df[df['Species Common'] == 'Schubert Chokecherry']
dffa = dff.groupby(['Borough', 'Health']).sum()
dffb = dff.groupby(['Borough']).sum()
dffp = (dffa / dffb).reset_index()

fig = px.bar(dffp, x = "Borough", y = "Count", color = "Health", title="Wide-Form Input")
fig.show()
pd.Categorical(df['Species Common'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21157218001168906, 'fraction_numerical': 0.014611338398597311, 'mean_word_length': 6.541850220264317, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '578687', 'license': 'CC0-1.0', 'n_tokens_mistral': 700, 'n_tokens_neox': 696, 'n_words': 110, 'path': 'm04/data-prep/tree-census.ipynb', 'repo_name': 'adamleerich/cuny-608-visual-analytics', 'size': '1711'}