Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

GEP475GROUPINEEDANAP

Views: 1461
Kernel: Python 3 (Anaconda)
import pandas as pd import numpy as np
netatmo = pd.read_csv('NetAtmo_2016.csv', parse_dates=True, index_col=1)
%matplotlib inline netatmo['CO2'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f0c9a720588>
Image in a Jupyter notebook
delta_CO2 = netatmo['CO2'].diff(1)
# calculate difference between time samples in seconds netatmo['time'] = netatmo.index delta_time = netatmo['time'].diff(1) / np.timedelta64(1,'s') slopes = delta_CO2 / delta_time
# slopes in units of ppm per second %matplotlib inline #(delta_CO2.values / delta_time).plot() slopes.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f0c9a23e0f0>
Image in a Jupyter notebook
slopes.describe()
count 9.013100e+04 mean NaN std NaN min -inf 25% -2.000000e-02 50% 0.000000e+00 75% 1.666667e-02 max inf dtype: float64
neg_slopes = slopes[slopes<0]
yearsdecay = (neg_slopes * netatmo['CO2']) (yearsdecay).plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f0c9a25a2b0>
Image in a Jupyter notebook
yearsdecay.to_csv('ETC-Weather-2016.csv') year1= pd.read_csv('ETC-Weather-2016.csv', parse_dates=True, index_col=1)
year1.dtypes
2016-02-19 13:26:00 object dtype: object
year1.head()
2016-02-19 13:26:00
NaN 2016-02-19 13:27:00
NaN 2016-02-19 13:27:00
NaN 2016-02-19 13:31:00
-5.533333 2016-02-19 13:36:00
-4.373333 2016-02-19 13:41:00
year1.describe()
2016-02-19 13:26:00
count 90148
unique 90126
top 2016-03-03 04:47:00
freq 4
year1.hist(bins=20)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-16-4fa8fb5997c0> in <module>() ----> 1 year1.hist(bins=20) /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_core.py in hist_frame(data, column, by, grid, xlabelsize, xrot, ylabelsize, yrot, ax, sharex, sharey, figsize, layout, bins, **kwds) 2176 fig, axes = _subplots(naxes=naxes, ax=ax, squeeze=False, 2177 sharex=sharex, sharey=sharey, figsize=figsize, -> 2178 layout=layout) 2179 _axes = _flatten(axes) 2180 /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_tools.py in _subplots(naxes, sharex, sharey, squeeze, subplot_kw, ax, layout, layout_type, **fig_kw) 235 236 # Create first subplot separately, so we can share it if requested --> 237 ax0 = fig.add_subplot(nrows, ncols, 1, **subplot_kw) 238 239 if sharex: /ext/anaconda3/lib/python3.5/site-packages/matplotlib/figure.py in add_subplot(self, *args, **kwargs) 1072 self._axstack.remove(ax) 1073 -> 1074 a = subplot_class_factory(projection_class)(self, *args, **kwargs) 1075 1076 self._axstack.add(key, a) /ext/anaconda3/lib/python3.5/site-packages/matplotlib/axes/_subplots.py in __init__(self, fig, *args, **kwargs) 62 raise ValueError( 63 "num must be 1 <= num <= {maxn}, not {num}".format( ---> 64 maxn=rows*cols, num=num)) 65 self._subplotspec = GridSpec(rows, cols)[int(num) - 1] 66 # num - 1 for converting from MATLAB to python indexing ValueError: num must be 1 <= num <= 0, not 1
<matplotlib.figure.Figure at 0x7f0c94971cc0>
data = pd.read_csv('NetAtmo_2016.csv', parse_dates=True, index_col=1)
data.head()
data.dtypes
data['Timestamp'] = data.index
data.index
start_time = '2016-11-19 13:26:00' end_time = '2016-12-31 23:55:00' date_range = (data['Timestamp'] >= start_time) & (data['Timestamp'] <= end_time)
%matplotlib inline data.loc[date_range].plot()
data['2016-02-19 13:26':'2016-02-19 13:32']['Timestamp'].diff(1)
data.loc[date_range] = data_range data_range ['CO2']
data.loc[date_range]
%matplotlib inline (delta_CO2.values / delta_time).plot()
data.head()