Operations on timestamp data
The date range is converted into a dataframe with the help of pd.DataFrame() method. The column is converted to DateTime using to_datetime() method. info() method gives information about the dataframe if there are any null values and the datatype of the columns.
Python3
# importing pandas import pandas as pd # creating a date range Date_range = pd.date_range(start = '1/12/2020' , end = '20/5/2021' , freq = 'M' ) # creating a Dataframe Data = pd.DataFrame(Date_range, columns = [ 'Date' ]) # converting the column to datetime Data[ 'Date' ] = pd.to_datetime(Data[ 'Date' ]) print (Data.info()) |
Output:
<class 'pandas.core.frame.DataFrame'> RangeIndex: 16 entries, 0 to 15 Data columns (total 1 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Date 16 non-null datetime64[ns] dtypes: datetime64[ns](1) memory usage: 256.0 bytes
Manipulating Time Series Data in Python
A collection of observations (activity) for a single subject (entity) at various time intervals is known as time-series data. In the case of metrics, time series are equally spaced and in the case of events, time series are unequally spaced. We may add the date and time for each record in this Pandas module, as well as fetch dataframe records and discover data inside a specific date and time range.
Contact Us