| Download
GEP475GROUPINEEDANAP
Path: InfiltrationHUB / Methods / 1.RawDataFixing_Concat_CO2.isolation / IsolateCO2&Concatenating.ipynb
Views: 1461Kernel: Python 3 (Anaconda)
Creating New "CO2 only" csv files, from orginal Netatmo csvs
making sure both files have same index and same column name for CO2
In [13]:
In [2]:
Timestamp | Temperature | Humidity | CO2 | Noise | Pressure | |
---|---|---|---|---|---|---|
Timezone : America/Los_Angeles | ||||||
2016-02-19 13:26:00 | 1455917199 | 18.8 | 76 | NaN | NaN | 1015.7 |
2016-02-19 13:27:00 | 1455917255 | 19.2 | 75 | 718.0 | NaN | 1015.7 |
2016-02-19 13:27:00 | 1455917257 | 19.9 | 73 | NaN | NaN | 1015.7 |
2016-02-19 13:31:00 | 1455917513 | 20.3 | 73 | 337.0 | 44.0 | 1015.8 |
2016-02-19 13:36:00 | 1455917814 | 21.2 | 70 | 332.0 | 47.0 | 1015.7 |
In [3]:
Timestamp | Temperature | Humidity | CO2 | Noise | Pressure | |
---|---|---|---|---|---|---|
count | 9.014300e+04 | 90143.000000 | 90143.000000 | 90137.000000 | 90132.000000 | 90143.000000 |
mean | 1.469613e+09 | 22.766724 | 51.291637 | 550.204799 | 38.964730 | 1011.348933 |
std | 7.900773e+06 | 1.592268 | 6.929620 | 318.321732 | 7.100703 | 4.217541 |
min | 1.455917e+09 | 17.900000 | 27.000000 | 201.000000 | 35.000000 | 995.000000 |
25% | 1.462765e+09 | 21.700000 | 49.000000 | 354.000000 | 36.000000 | 1008.300000 |
50% | 1.469657e+09 | 22.900000 | 52.000000 | 416.000000 | 36.000000 | 1011.000000 |
75% | 1.476459e+09 | 23.800000 | 55.000000 | 639.000000 | 38.000000 | 1014.100000 |
max | 1.483257e+09 | 28.500000 | 76.000000 | 2777.000000 | 79.000000 | 1027.500000 |
In [0]:
In [4]:
Timestamp | Temperature | Humidity | CO2 | Noise | Pressure | |
---|---|---|---|---|---|---|
Time | ||||||
2017-01-01 00:00:00 | 1483257658 | 21.8 | 34 | 482 | 39 | 1009.1 |
2017-01-01 00:05:00 | 1483257959 | 21.8 | 34 | 491 | 41 | 1009.2 |
2017-01-01 00:11:00 | 1483258260 | 21.9 | 34 | 480 | 39 | 1009.2 |
2017-01-01 00:16:00 | 1483258562 | 21.9 | 34 | 486 | 39 | 1009.2 |
2017-01-01 00:21:00 | 1483258864 | 21.9 | 34 | 490 | 37 | 1009.3 |
above you can see, the 2016 csv (year1) did not have the same index as the 2017 file.
How to change:
In [5]:
Timestamp | Temperature | Humidity | CO2 | Noise | Pressure | |
---|---|---|---|---|---|---|
Time | ||||||
2016-02-19 13:26:00 | 1455917199 | 18.8 | 76 | NaN | NaN | 1015.7 |
2016-02-19 13:27:00 | 1455917255 | 19.2 | 75 | 718.0 | NaN | 1015.7 |
2016-02-19 13:27:00 | 1455917257 | 19.9 | 73 | NaN | NaN | 1015.7 |
2016-02-19 13:31:00 | 1455917513 | 20.3 | 73 | 337.0 | 44.0 | 1015.8 |
2016-02-19 13:36:00 | 1455917814 | 21.2 | 70 | 332.0 | 47.0 | 1015.7 |
Now that we have the same index, we'll go ahead and create the new files.
isolating the CO2 data
In [6]:
In [7]:
using to_csv
In [8]:
In [9]:
ppm | |
---|---|
Time | |
2016-02-19 13:26:00 | NaN |
2016-02-19 13:27:00 | 718.0 |
2016-02-19 13:27:00 | NaN |
2016-02-19 13:31:00 | 337.0 |
2016-02-19 13:36:00 | 332.0 |
In [10]:
In [11]:
In [12]:
ppm | |
---|---|
Time | |
2017-01-01 00:00:00 | 482 |
2017-01-01 00:05:00 | 491 |
2017-01-01 00:11:00 | 480 |
2017-01-01 00:16:00 | 486 |
2017-01-01 00:21:00 | 490 |
Next, I want to create another csv file that has the column names already inside. (I dont know a better way)*
In [14]:
In [15]:
ppm | |
---|---|
Time | |
2017-01-01 00:00:00 | 482 |
2017-01-01 00:05:00 | 491 |
2017-01-01 00:11:00 | 480 |
2017-01-01 00:16:00 | 486 |
2017-01-01 00:21:00 | 490 |
Now we are left with the last two files, 2016 and 2017 CO2ONLY, and need to combine them
Using Concatenate
In [16]:
In [17]:
These cells are just to convince myself the data was combined correctly
In [18]:
ppm | |
---|---|
count | 100985.000000 |
mean | 547.646878 |
std | 304.511307 |
min | 201.000000 |
25% | 362.000000 |
50% | 438.000000 |
75% | 615.000000 |
max | 2777.000000 |
In [19]:
Time | ppm | |
---|---|---|
0 | 2016-02-19 13:26:00 | NaN |
1 | 2016-02-19 13:27:00 | 718.0 |
2 | 2016-02-19 13:27:00 | NaN |
3 | 2016-02-19 13:31:00 | 337.0 |
4 | 2016-02-19 13:36:00 | 332.0 |
In [20]:
In [21]:
In [22]:
In [23]:
In [24]:
In [25]:
Now, finally, we make the last csv file. It will include all the CO2 data from years 2016 and 2017
In [26]:
In [27]:
Unnamed: 0 | ppm | |
---|---|---|
Time | ||
2016-02-19 13:26:00 | 0 | NaN |
2016-02-19 13:27:00 | 1 | 718.0 |
2016-02-19 13:27:00 | 2 | NaN |
2016-02-19 13:31:00 | 3 | 337.0 |
2016-02-19 13:36:00 | 4 | 332.0 |
here, I'd like to make another csv without the extra columb.. HELP SOTO
In [28]:
In [29]:
Time
2016-02-19 13:26:00 NaN
2016-02-19 13:27:00 718.0
2016-02-19 13:27:00 NaN
2016-02-19 13:31:00 337.0
2016-02-19 13:36:00 332.0
Name: ppm, dtype: float64
In [30]:
In [31]:
Unnamed: 1 | |
---|---|
2016-02-19 13:26:00 | |
2016-02-19 13:27:00 | 718.0 |
2016-02-19 13:27:00 | NaN |
2016-02-19 13:31:00 | 337.0 |
2016-02-19 13:36:00 | 332.0 |
2016-02-19 13:41:00 | 328.0 |
In [0]: