Plotting data 20180201-2223




Pay Notebook Creator: Karsh Patel0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0
In [6]:
# CrossCompute
url = "https://data.cityofnewyork.us/api/views/c3uy-2p5r/rows.csv?accessType=DOWNLOAD"
target_folder = '/tmp'
In [7]:
# Milestone 1
# Show a graph for air quality of NYC for Toxin-Indicator ID(646)
In [8]:
borough_select.strip().splitlines()[0]
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-69e5ca716b3c> in <module>()
----> 1 borough_select.strip().splitlines()[0]

NameError: name 'borough_select' is not defined
In [9]:
# Load Data
import pandas as pd
t = pd.read_csv(url)
t.head()
Out[9]:
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style>
indicator_data_id indicator_id name Measure geo_type_name geo_entity_id geo_entity_name year_description data_valuemessage
0 130728 646 Air Toxics Concentrations- Average Benzene Con... Average Concentration Borough 1 Bronx 2005 2.8
1 130729 646 Air Toxics Concentrations- Average Benzene Con... Average Concentration Borough 2 Brooklyn 2005 2.8
2 130730 646 Air Toxics Concentrations- Average Benzene Con... Average Concentration Borough 3 Manhattan 2005 4.7
3 130731 646 Air Toxics Concentrations- Average Benzene Con... Average Concentration Borough 4 Queens 2005 1.9
4 130732 646 Air Toxics Concentrations- Average Benzene Con... Average Concentration Borough 5 Staten Island 2005 1.6
In [10]:
# Aggreggate data for the selected toxin 646 over all locations
In [11]:
len(t)
Out[11]:
2769
In [12]:
x = t[(t['indicator_id'] == 646)].copy()
In [13]:
%pylab inline
ax = x.plot(x=['year_description'], y=['indicator_data_id'])
Populating the interactive namespace from numpy and matplotlib
/home/user/.virtualenvs/crosscompute/lib/python3.6/site-packages/pandas/plotting/_core.py:1716: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
  series.name = label
In [14]:
# Save graph
from os.path import join
fig = ax.get_figure()
target_path = join(target_folder, 'graph.png')
fig.savefig(target_path)
print('x_image_path = %s' % target_path)
x_image_path = /tmp/graph.png