October 2019
Beginner to intermediate
674 pages
16h 43m
English
Let's read them and concatenate them to make a single file:
import pandas as pd import os os.chdir(' ') ts1=pd.read_csv('datatraining.txt') ts2=pd.read_csv('datatest.txt') ts3=pd.read_csv('datatest2.txt') ts=pd.concat([ts1,ts2,ts3]
Before using the date column as an index, we will convert it to a datetime format and drop the actual date column:
ts['datetime'] = pd.to_datetime(ts['date'])
ts = ts.set_index('datetime')
ts.drop(['date'], axis=1, inplace=True)
Once the new datetime column is set to an index, it can be used for subsetting. For example, for filtering all the records for a particular day, we can just enclose the data inside the subsetting (square, []) brackets:
ts['2015-02-05'] ...
Read now
Unlock full access