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

Boolean इंडेक्सिंग और Matplotlib के साथ मज़ेदार अभ्यास

अब देखते हैं कि Boolean इंडेक्सिंग कुछ ही लाइनों के कोड में हमें डेटा को विज़ुअली कैसे एक्सप्लोर करने में मदद करती है। इस अभ्यास में, आप वे कई चीजें दोहराएँगे जो आपने सीखी हैं — एक dictionary से डेटा को उपयोगी pandas DataFrame में बदलना, Booleans से इंडेक्सिंग करना, और फिर matplotlib का उपयोग करके अपने डेटा को visualize करना ताकि wildlife strikes डेटा में कुछ संबंधों के बारे में जान सकें.

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

MATLAB उपयोगकर्ताओं के लिए Python

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

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

  • strikes dictionary को एक DataFrame में कन्वर्ट करें.
  • 'Engine' कॉलम में 'Turbofan' के लिए एक Boolean फ़िल्टर बनाएँ.
  • 'Engine' कॉलम में 'Turboprop' के लिए एक Boolean फ़िल्टर बनाएँ.
  • turbofan और turboprop का उपयोग करते हुए strikes डेटासेट को फ़िल्टर करके दो scatter प्लॉट बनाएँ.

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

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

# Create a dictionary and then a DataFrame from the dictionary
strikes = {'Date': date,'Speed': speed,'Height':height,'Engine':engine}
strikes = pd.____(strikes)

# Filter strikes by engine type
turbofan = strikes['Engine']=='____'
turboprop = strikes['____']=='____'

# Create scatter plot of speed and height for each engine type
plt.scatter(strikes[____]['Speed'],strikes[____]['Height'],label='Turbofan')
plt.scatter(strikes[____]['Speed'],strikes[____]['Height'],label='Turboprop')
plt.legend()
plt.xlabel('Strike speed (knots)')
plt.ylabel('Strike height (feet)')
plt.show()
कोड संपादित करें और चलाएँ