Missing values इम्प्यूट करना
जब आपके पास missing डेटा पॉइंट्स हों, तो आप उन्हें कैसे भरेंगे?
इस अभ्यास में, आप अलग-अलग interpolation तरीकों का इस्तेमाल करके कुछ missing values भरने का अभ्यास करेंगे और हर बार उसके नतीजों का visualization करेंगे। लेकिन पहले, आप वह फंक्शन (interpolate_and_plot()) बनाएँगे जिसका उपयोग आप missing डेटा पॉइंट्स को interpolate करने और उन्हें plot करने के लिए करेंगे।
एक सिंगल time series पहले से prices नाम के DataFrame में लोड की गई है।
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Time Series Data के लिए Machine Learning
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create a function we'll use to interpolate and plot
def interpolate_and_plot(prices, interpolation):
# Create a boolean mask for missing values
missing_values = prices.____()
# Interpolate the missing values
prices_interp = prices.____(interpolation)
# Plot the results, highlighting the interpolated values in black
fig, ax = plt.subplots(figsize=(10, 5))
prices_interp.plot(color='k', alpha=.6, ax=ax, legend=False)
# Now plot the interpolated values on top in red
prices_interp[missing_values].plot(ax=ax, color='r', lw=3, legend=False)
plt.show()