<jupyter_start><jupyter_text>Meta Data Exploration<NAME> -- <EMAIL>This notebook gives an overview of the buildings in this study<jupyter_code>import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import os
%matplotlib inline
repos_path = "/Users/Clayton/temporal-features-for-buildings/"
meta = pd.read_csv(os.path.join(repos_path,"data/raw/meta_open.csv"), index_col='uid', parse_dates=["datastart","dataend"], dayfirst=True)
meta.info()
sns.set_style("whitegrid")<jupyter_output><empty_output><jupyter_text>Create Bar ChartsUse: http://stanford.edu/~mwaskom/software/seaborn/examples/horizontal_barplot.html<jupyter_code>meta.info()#[['industry','timezone']].head()
meta.head()
df = pd.pivot_table(meta.reset_index(), index='timezone', columns='subindustry', values='uid', aggfunc='count')
df
# crashes = sns.load_dataset("car_crashes").sort_values("total", ascending=False)
location = pd.DataFrame(meta.timezone.value_counts()).reset_index()

location
def createbarchart(df, column, ylabel, color, filelabel):
    # Initialize the matplotlib figure
    #sns.set_context('poster', font_scale=1)    
    location = pd.DataFrame(df[column].value_counts()).reset_index()

    f, ax = plt.subplots(figsize=(9, 5))

    sns.set_color_codes("pastel")
    sns.barplot(x=column, y="index", data=location[:15], color=color)

    # Add a legend and informative axis label
    ax.legend(ncol=2, loc="lower right", frameon=True)
    ax.set(ylabel=ylabel,
           xlabel="Number of Buildings")
    sns.despine(left=True, bottom=True)
    plt.subplots_adjust(left=0.3)
    plt.tight_layout()
    plt.savefig(os.path.join(repos_path,"reports/figures/metadataoverview/"+filelabel+".png"))
location[:15]
meta["string_starttime"] = meta.datastart.apply(lambda x: str(x.date()))
sns.set_context("paper", font_scale=2)                                                  
createbarchart(meta, "string_starttime", "Data Starting Time", "m","starttimesbar")
#sns.set_style("white")
createbarchart(meta, "timezone", "Time Zones", "b","timezonesbar")
createbarchart(meta, "industry", "Industry", "r", "bar_industry")
createbarchart(meta, "subindustry", "Sub-Industry", "g","bar_subindustry")
createbarchart(meta, "primaryspaceusage", "Primary Use", "y", "bar_primaryspaceuse")<jupyter_output><empty_output><jupyter_text>Create 4 bar charts in a set of panels<jupyter_code>import numpy as np
# Simple data to display in various forms
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)


# row and column sharing
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex='col', sharey='row')
ax1.plot(x, y)
ax1.set_title('Sharing x per column, y per row')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
ax4.plot(x, 2 * y ** 2 - 1, color='r')
sns.set_color_codes("pastel")
sns.set_context(font_scale=1)
import matplotlib.gridspec as gridspec

plt.figure(figsize=(18,10))
gs = gridspec.GridSpec(2, 8)
#f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(20, 9))#
# ax = plt.subplot2grid((2,2),(0, 0))

location = pd.DataFrame(meta["timezone"].value_counts()).reset_index()
ax1 = plt.subplot(gs[0,0:4])
ax1 = sns.barplot(x="timezone", y="index", data=location[:15], color="b")
ax1.legend(ncol=2, loc="lower right", frameon=True)
ax1.set(ylabel="Time Zones", xlabel="Number of Buildings")

location = pd.DataFrame(meta["industry"].value_counts()).reset_index()
ax2 = plt.subplot(gs[0,4:])
ax2 = sns.barplot(x="industry", y="index", data=location[:15], color="g")
ax2.legend(ncol=2, loc="lower right", frameon=True)
ax2.set(ylabel="Industry", xlabel="Number of Buildings")

location = pd.DataFrame(meta["subindustry"].value_counts()).reset_index()
ax3 = plt.subplot(gs[1,0:4])
ax3 = sns.barplot(x="subindustry", y="index", data=location[:15], color="r")
ax3.legend(ncol=2, loc="lower right", frameon=True)
ax3.set(ylabel="Sub-Industry", xlabel="Number of Buildings")

location = pd.DataFrame(meta["primaryspaceusage"].value_counts()).reset_index()
ax4 = plt.subplot(gs[1,4:])
ax4 = sns.barplot(x="primaryspaceusage", y="index", data=location[:15], color="y")
ax4.legend(ncol=2, loc="lower right", frameon=True)
ax4.set(ylabel="Primary Use", xlabel="Number of Buildings")

sns.despine(left=True, bottom=True)
plt.subplots_adjust(left=0.3)
plt.tight_layout()
plt.savefig(os.path.join(repos_path,"reports/figures/metadataoverview/allbars.pdf"))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17800091282519398, 'fraction_numerical': 0.02190780465540849, 'mean_word_length': 6.530927835051546, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '496516', 'license': 'MIT', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1630, 'n_words': 290, 'path': 'notebooks/00_Meta Data Exploration.ipynb', 'repo_name': 'manojm18/the-building-data-genome-project', 'size': '4407'}