0
0
Data Analysis Pythondata~20 mins

Why time-based analysis reveals trends in Data Analysis Python - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Time Series Trend Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this time series rolling mean calculation?

Given a time series data, what is the output of the rolling mean calculation shown below?

Data Analysis Python
import pandas as pd

data = pd.Series([10, 20, 30, 40, 50], index=pd.date_range('2024-01-01', periods=5))
rolling_mean = data.rolling(window=3).mean()
print(rolling_mean.tolist())
A[nan, nan, 20.0, 30.0, 40.0]
B[10.0, 15.0, 20.0, 30.0, 40.0]
C[nan, 15.0, 20.0, 30.0, 40.0]
D[10.0, 20.0, 30.0, 40.0, 50.0]
Attempts:
2 left
💡 Hint

Remember, rolling mean with window=3 needs 3 values to compute the first mean.

data_output
intermediate
2:00remaining
How many peaks are detected in this time series data?

Using the following time series data, how many peaks are detected by the code?

Data Analysis Python
import numpy as np
from scipy.signal import find_peaks

data = np.array([1, 3, 7, 1, 2, 6, 0, 1])
peaks, _ = find_peaks(data)
print(len(peaks))
A2
B1
C4
D3
Attempts:
2 left
💡 Hint

Peaks are points higher than their neighbors.

visualization
advanced
3:00remaining
Which plot shows a clear upward trend over time?

Given these four plots of time series data, which one clearly shows an upward trend?

Data Analysis Python
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

dates = pd.date_range('2024-01-01', periods=50)
data1 = pd.Series(np.random.normal(0, 1, 50), index=dates)
data2 = pd.Series(np.linspace(0, 10, 50) + np.random.normal(0, 1, 50), index=dates)
data3 = pd.Series(np.sin(np.linspace(0, 10, 50)), index=dates)
data4 = pd.Series(np.random.normal(5, 1, 50), index=dates)

plt.figure(figsize=(10, 6))
plt.subplot(2, 2, 1)
plt.plot(data1)
plt.title('A')

plt.subplot(2, 2, 2)
plt.plot(data2)
plt.title('B')

plt.subplot(2, 2, 3)
plt.plot(data3)
plt.title('C')

plt.subplot(2, 2, 4)
plt.plot(data4)
plt.title('D')

plt.tight_layout()
plt.show()
APlot B
BPlot D
CPlot C
DPlot A
Attempts:
2 left
💡 Hint

Look for a steady increase in values over time.

🔧 Debug
advanced
2:00remaining
What error does this time series resampling code produce?

What error will this code raise when trying to resample a time series?

Data Analysis Python
import pandas as pd

data = pd.Series([1, 2, 3], index=[1, 2, 3])
resampled = data.resample('D').mean()
print(resampled)
AValueError: Invalid frequency string
BAttributeError: 'Series' object has no attribute 'resample'
CTypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index'
DNo error, prints resampled data
Attempts:
2 left
💡 Hint

Check the index type required for resampling.

🚀 Application
expert
3:00remaining
Which method best reveals seasonal trends in monthly sales data?

You have monthly sales data for 5 years. Which method best reveals seasonal trends?

ACalculate daily differences between sales values
BCalculate a 12-month rolling average to smooth data
CPlot histogram of sales values
DUse linear regression on raw monthly sales
Attempts:
2 left
💡 Hint

Seasonal trends repeat every year, so smoothing over 12 months helps.