Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

GEP475GROUPINEEDANAP

Views: 1461
Kernel: Python 3
import pandas as pd import numpy as np
PPM = pd.read_csv('NatatmoCleanedForInfiltrationAnalysis.csv', parse_dates=True, index_col=1)
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-4-4ed48fd0b1d8> in <module>() ----> 1 PPM = pd.read_csv('NatatmoCleanedForInfiltrationAnalysis.csv', parse_dates=True, index_col=1) ~/anaconda3/lib/python3.6/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision) 653 skip_blank_lines=skip_blank_lines) 654 --> 655 return _read(filepath_or_buffer, kwds) 656 657 parser_f.__name__ = name ~/anaconda3/lib/python3.6/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds) 403 404 # Create the parser. --> 405 parser = TextFileReader(filepath_or_buffer, **kwds) 406 407 if chunksize or iterator: ~/anaconda3/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds) 762 self.options['has_index_names'] = kwds['has_index_names'] 763 --> 764 self._make_engine(self.engine) 765 766 def close(self): ~/anaconda3/lib/python3.6/site-packages/pandas/io/parsers.py in _make_engine(self, engine) 983 def _make_engine(self, engine='c'): 984 if engine == 'c': --> 985 self._engine = CParserWrapper(self.f, **self.options) 986 else: 987 if engine == 'python': ~/anaconda3/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds) 1603 kwds['allow_leading_cols'] = self.index_col is not False 1604 -> 1605 self._reader = parsers.TextReader(src, **kwds) 1606 1607 # XXX pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__ (pandas/_libs/parsers.c:4209)() pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source (pandas/_libs/parsers.c:8873)() FileNotFoundError: File b'NatatmoCleanedForInfiltrationAnalysis.csv' does not exist
%matplotlib inline PPM['ppm'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f4384188e80>
Image in a Jupyter notebook
delta_CO2 = PPM['ppm'].diff(1)
PPM['Time'] = PPM.index delta_time = PPM['Time'].diff(1) / np.timedelta64(1,'m') slopes = delta_CO2 / delta_time
%matplotlib inline slopes.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f438341b8d0>
Image in a Jupyter notebook
slopes.describe()
count 1.009790e+05 mean NaN std NaN min -inf 25% -1.200000e+00 50% 0.000000e+00 75% 1.000000e+00 max inf dtype: float64
slopes.head()
Time 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 -1.0 dtype: float64
neg_slopes = slopes[slopes<0]
yearsdecay = (neg_slopes * PPM['ppm']) (yearsdecay).plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f4383715d30>
Image in a Jupyter notebook
(yearsdecay).head()
Time 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 -332.0 dtype: float64

made Infiltration csv (perhaps for detailed reference later)

yearsdecay.to_csv('Infiltration_Rate.cvs')
column_names = ['Time', 'ppm/min'] In= pd.read_csv('Infiltration_Rate.cvs', parse_dates=True, index_col=0, names = column_names) In.head()
ppm/min
Time
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 -332.0
In.describe()
ppm/min
count 4.885000e+04
mean -inf
std NaN
min -inf
25% -1.046850e+03
50% -5.160000e+02
75% -2.460000e+02
max -2.306667e+01
In = In.replace([np.inf, -np.inf], np.nan) In.describe()
ppm/min
count 48848.000000
mean -1141.663669
std 3186.375410
min -206960.600000
25% -1046.400000
50% -516.000000
75% -246.000000
max -23.066667
#In.plot()
In.hist(bins=1000)
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f4382e699e8>]], dtype=object)
Image in a Jupyter notebook
In.hist(bins=10000)
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f4382df5160>]], dtype=object)
Image in a Jupyter notebook
In.hist(bins=[-5000,-1000,-900,-850,-800,-750,-700,-650,-550,-500,-450,-400,-350,-300,-250,-200,0])
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f437f04c358>]], dtype=object)
Image in a Jupyter notebook

Question for Soto: how to make bins small enough to fit each value, or at least equal to the average difference

In.hist(bins=[-1000,-900,-800,-700,-600,-500,-400,-300,-200,-100,0])
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f43834fc828>]], dtype=object)
Image in a Jupyter notebook
In.hist(bins=[-700,-699,-698,-697,-696,-600,-550,-525,-500,-400,-300,-200,-100,0])
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f437de3b2b0>]], dtype=object)
Image in a Jupyter notebook

This needs some work

min_val = -4000 max_val = 0 num_bins = 1000 my_bins = np.linspace(min_val, max_val, num_bins) In.hist(bins=np.r_[-np.inf, my_bins, np.inf])
/ext/anaconda3/lib/python3.5/site-packages/matplotlib/axes/_axes.py:6277: RuntimeWarning: invalid value encountered in add patch = _barfunc(bins[:-1]+boffset, height, width, /ext/anaconda3/lib/python3.5/site-packages/matplotlib/axes/_axes.py:2105: RuntimeWarning: invalid value encountered in double_scalars left = [left[i] - width[i] / 2. for i in xrange(len(left))]
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f437d8a0b70>]], dtype=object)
Image in a Jupyter notebook
In.kdeplot()
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-23-a2f1855ae631> in <module>() ----> 1 In.kdeplot() /ext/anaconda3/lib/python3.5/site-packages/pandas/core/generic.py in __getattr__(self, name) 3079 if name in self._info_axis: 3080 return self[name] -> 3081 return object.__getattribute__(self, name) 3082 3083 def __setattr__(self, name, value): AttributeError: 'DataFrame' object has no attribute 'kdeplot'
In.plot.area(stacked=False);
In.plot(kind='kde', xlim=[0, 100000])