शुरू करेंमुफ़्त में शुरू करें

अपने time series प्लॉट में summary statistics जोड़ें

pandas API to matplotlib और table मेथड का उपयोग करके आप एक ही ग्राफ़ पर time series प्लॉट और numerical summaries दोनों को विज़ुअलाइज़ कर सकते हैं:

# Plot the time series data in the DataFrame
ax = df.plot()

# Compute summary statistics of the df DataFrame
df_summary = df.describe()

# Add summary table information to the plot
ax.table(cellText=df_summary.values, 
         colWidths=[0.3]*len(df.columns), 
         rowLabels=df_summary.index, 
         colLabels=df_summary.columns, 
         loc='top')

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Time Series Data का विज़ुअलाइज़ेशन

पाठ्यक्रम देखें

अभ्यास निर्देश

शेल में meat_mean देखें — यह एक DataFrame है जिसमें meat की सभी time series का mean शामिल है.

  • meat_mean के सभी मान cellText आर्ग्यूमेंट में असाइन करें.
  • meat_mean के इंडेक्स के सभी मान rowLabels आर्ग्यूमेंट में असाइन करें.
  • meat_mean के कॉलम नाम colLabels आर्ग्यूमेंट में असाइन करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Plot the meat data
ax = meat.plot(fontsize=6, linewidth=1)

# Add x-axis labels
ax.set_xlabel('Date', fontsize=6)

# Add summary table information to the plot
ax.table(cellText=meat_mean.____,
         colWidths = [0.15]*len(meat_mean.columns),
         rowLabels=meat_mean.____,
         colLabels=meat_mean.____,
         loc='top')

# Specify the fontsize and location of your legend
ax.legend(loc='upper center', bbox_to_anchor=(0.5, 0.95), ncol=3, fontsize=6)

# Show plot
plt.show()
कोड संपादित करें और चलाएँ