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)
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(3,'m') slopes = delta_CO2 / delta_time
neg_slopes = slopes[slopes<0]
infiltration = (neg_slopes * netatmo['CO2']) (infiltration).plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f8b7018c4a8>
Image in a Jupyter notebook
#ETC lecture all volume = 21,150 ft^3
infiltration.head()
Timezone : America/Los_Angeles 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 NaN 2016-02-19 13:36:00 -996.0 dtype: float64
infiltration.describe()
count 4.366200e+04 mean -inf std NaN min -inf 25% -3.143400e+03 50% -1.512000e+03 75% -7.200000e+02 max -6.920000e+01 dtype: float64
infiltration = infiltration.replace([np.inf, -np.inf], np.nan)
infiltration.describe()
count 43660.000000 mean -3456.018362 std 9638.973828 min -620881.800000 25% -3142.950000 50% -1512.000000 75% -720.000000 max -69.200000 dtype: float64
infiltration.hist()
<matplotlib.axes._subplots.AxesSubplot at 0x7fdd32dc2358>
Image in a Jupyter notebook
infiltration.head()
Timezone : America/Los_Angeles 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 NaN 2016-02-19 13:36:00 -996.0 dtype: float64
infiltration.dtypes
dtype('O')
infiltration.head()
Timezone : America/Los_Angeles 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 NaN 2016-02-19 13:36:00 -996 dtype: object
happyhist = (infiltration[(infiltration.index)] >= -6000000) & (infiltration[(infiltration.index)] <= 0)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-123-992418035f8f> in <module>() ----> 1 happyhist = (infiltration[(infiltration.index)] >= -6000000) & (infiltration[(infiltration.index)] <= 0) /projects/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py in wrapper(self, other, axis) 853 854 with np.errstate(all='ignore'): --> 855 res = na_op(values, other) 856 if isscalar(res): 857 raise TypeError('Could not compare %s type with Series' % /projects/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py in na_op(x, y) 757 758 if is_object_dtype(x.dtype): --> 759 result = _comp_method_OBJECT_ARRAY(op, x, y) 760 else: 761 /projects/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py in _comp_method_OBJECT_ARRAY(op, x, y) 737 result = lib.vec_compare(x, y, op) 738 else: --> 739 result = lib.scalar_compare(x, y, op) 740 return result 741 pandas/lib.pyx in pandas.lib.scalar_compare (pandas/lib.c:14847)() /projects/anaconda3/lib/python3.5/site-packages/pandas/indexes/base.py in _evaluate_compare(self, other) 3361 with np.errstate(all='ignore'): 3362 result = _comp_method_OBJECT_ARRAY( -> 3363 op, self.values, other) 3364 else: 3365 with np.errstate(all='ignore'): /projects/anaconda3/lib/python3.5/site-packages/pandas/core/ops.py in _comp_method_OBJECT_ARRAY(op, x, y) 737 result = lib.vec_compare(x, y, op) 738 else: --> 739 result = lib.scalar_compare(x, y, op) 740 return result 741 pandas/lib.pyx in pandas.lib.scalar_compare (pandas/lib.c:14847)() pandas/tslib.pyx in pandas.tslib._Timestamp.__richcmp__ (pandas/tslib.c:20491)() TypeError: Cannot compare type 'Timestamp' with type 'int'
happyhist.hist()
<matplotlib.axes._subplots.AxesSubplot at 0x7fdd32e95208>
Image in a Jupyter notebook
happyhist.hist(bins=5)
<matplotlib.axes._subplots.AxesSubplot at 0x7fdd32e32cf8>
Image in a Jupyter notebook
happyhist.describe()
count 90149 unique 2 top False freq 90148 dtype: object
yearsdecay.hist(bins=50)
<matplotlib.axes._subplots.AxesSubplot at 0x7fdd386c1e48>
Image in a Jupyter notebook
years.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-11-06 01:37:00
freq 4
years['CO2'] = years.index years.head()
2016-02-19 13:26:00 CO2
NaN 2016-02-19 13:27:00 NaN
NaN 2016-02-19 13:27:00 NaN
NaN 2016-02-19 13:31:00 NaN
-5.533333 2016-02-19 13:36:00 -5.533333
-4.373333 2016-02-19 13:41:00 -4.373333
print(years)
2016-02-19 13:26:00 CO2 NaN 2016-02-19 13:27:00 NaN NaN 2016-02-19 13:27:00 NaN NaN 2016-02-19 13:31:00 NaN -5.533333 2016-02-19 13:36:00 -5.533333 -4.373333 2016-02-19 13:41:00 -4.373333 -21.490000 2016-02-19 13:46:00 -21.490000 -10.853333 2016-02-19 13:51:00 -10.853333 -6.743333 2016-02-19 13:56:00 -6.743333 -7.000000 2016-02-19 14:02:00 -7.000000 -6.370000 2016-02-19 14:07:00 -6.370000 -0.906667 2016-02-19 14:12:00 -0.906667 -2.690000 2016-02-19 14:17:00 -2.690000 -1.780000 2016-02-19 14:22:00 -1.780000 NaN 2016-02-19 14:27:00 NaN NaN 2016-02-19 14:32:00 NaN NaN 2016-02-19 14:37:00 NaN NaN 2016-02-19 14:42:00 NaN NaN 2016-02-19 14:47:00 NaN -4.053333 2016-02-19 14:52:00 -4.053333 NaN 2016-02-19 14:57:00 NaN -3.190000 2016-02-19 15:02:00 -3.190000 NaN 2016-02-19 15:07:00 NaN NaN 2016-02-19 15:12:00 NaN NaN 2016-02-19 15:17:00 NaN NaN 2016-02-19 15:22:00 NaN NaN 2016-02-19 15:27:00 NaN NaN 2016-02-19 15:32:00 NaN NaN 2016-02-19 15:37:00 NaN NaN 2016-02-19 15:42:00 NaN -14.006667 2016-02-19 15:47:00 -14.006667 ... ... ... NaN 2016-12-31 21:30:00 NaN NaN 2016-12-31 21:35:00 NaN -3.200000 2016-12-31 21:40:00 -3.200000 NaN 2016-12-31 21:45:00 NaN -15.800000 2016-12-31 21:50:00 -15.800000 NaN 2016-12-31 21:55:00 NaN -26.293333 2016-12-31 22:00:00 -26.293333 NaN 2016-12-31 22:05:00 NaN NaN 2016-12-31 22:10:00 NaN -4.740000 2016-12-31 22:15:00 -4.740000 NaN 2016-12-31 22:20:00 NaN NaN 2016-12-31 22:25:00 NaN -32.970000 2016-12-31 22:30:00 -32.970000 NaN 2016-12-31 22:35:00 NaN NaN 2016-12-31 22:40:00 NaN -7.966667 2016-12-31 22:45:00 -7.966667 NaN 2016-12-31 22:50:00 NaN -3.173333 2016-12-31 22:55:00 -3.173333 NaN 2016-12-31 23:00:00 NaN -3.180000 2016-12-31 23:05:00 -3.180000 NaN 2016-12-31 23:10:00 NaN NaN 2016-12-31 23:15:00 NaN -4.840000 2016-12-31 23:20:00 -4.840000 -7.983333 2016-12-31 23:25:00 -7.983333 NaN 2016-12-31 23:30:00 NaN NaN 2016-12-31 23:35:00 NaN NaN 2016-12-31 23:40:00 NaN NaN 2016-12-31 23:45:00 NaN -22.166667 2016-12-31 23:50:00 -22.166667 NaN 2016-12-31 23:55:00 NaN [90148 rows x 2 columns]
years.hist(bins = 500)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-28-7cfb5adaf0d8> in <module>() ----> 1 years.hist(bins = 500) /projects/anaconda3/lib/python3.5/site-packages/pandas/tools/plotting.py in hist_frame(data, column, by, grid, xlabelsize, xrot, ylabelsize, yrot, ax, sharex, sharey, figsize, layout, bins, **kwds) 2924 for i, col in enumerate(_try_sort(data.columns)): 2925 ax = _axes[i] -> 2926 ax.hist(data[col].dropna().values, bins=bins, **kwds) 2927 ax.set_title(col) 2928 ax.grid(grid) /projects/anaconda3/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs) 1890 warnings.warn(msg % (label_namer, func.__name__), 1891 RuntimeWarning, stacklevel=2) -> 1892 return func(ax, *args, **kwargs) 1893 pre_doc = inner.__doc__ 1894 if pre_doc is None: /projects/anaconda3/lib/python3.5/site-packages/matplotlib/axes/_axes.py in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs) 6190 # this will automatically overwrite bins, 6191 # so that each histogram uses the same bins -> 6192 m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs) 6193 m = m.astype(float) # causes problems later if it's an int 6194 if mlast is None: /projects/anaconda3/lib/python3.5/site-packages/numpy/lib/function_base.py in histogram(a, bins, range, normed, weights, density) 503 if not np.all(np.isfinite([mn, mx])): 504 raise ValueError( --> 505 'range parameter must be finite.') 506 if mn == mx: 507 mn -= 0.5 ValueError: range parameter must be finite.
Image in a Jupyter notebook