Login using Social Account
     Continue with GoogleLogin using your credentials
It is very important for a time series to have a frequency set, so as to consolidate that the data we are working on is free of any missing data.
Since we are working with stock-exchange time-series data, it makes sense to set the frequency of the time-series to business days, meaning the data is recorded for weekdays but not any weekends.
Thanks to pandas, there is a readily available method asfreq()
to set the frequency for the time-series.
Note:
asfreq()
method converts the time-series to specified frequency.
We could pass an argument to the method to denote frequency. For example, df.asfreq('d')
implies to set the data to a daily frequency. Similarly,
'b' means business days
'30S' means 30 seconds
and so on.
First let us again check the shape of df_yahoo
.
print(df_yahoo.shape)
Now, use asfreq('b')
on df_yahoo
to set the frequency to business days and store it in yahoo_data
data frame.
yahoo_data = df_yahoo.<< your code comes here >>
Now let us see if there are any extra rows introduced after setting the frequency.
print(yahoo_data.shape)
View the last 30 rows of the newly formed yahoo_data
using tail()
.
yahoo_data.<< your code comes here >>
Observe that there are extra rows and some missing values after setting the frequency to business days.
Let us see the column wise null values in yahoo_data
using isnull().sum()
.
yahoo_data.<< you code comes here >>
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...