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

Categorical variables की गिनती

गिनती करना आपके डेटा का एक त्वरित ओवरव्यू पाने और ऐसी बातें पकड़ने का बढ़िया तरीका है जो अन्यथा शायद न दिखें. इस अभ्यास में, आप पिछले अभ्यास में बनाए गए DataFrames का उपयोग करके प्रत्येक प्रकार की स्टोर की संख्या और प्रत्येक department नंबर की संख्या गिनेंगे:

# Drop duplicate store/type combinations
store_types = sales.drop_duplicates(subset=["store", "type"])

# Drop duplicate store/department combinations
store_depts = sales.drop_duplicates(subset=["store", "department"])

पिछले अभ्यास में बनाए गए store_types और store_depts DataFrames उपलब्ध हैं, और pandas को pd के रूप में इम्पोर्ट किया गया है.

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

pandas के साथ Data Manipulation

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

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

  • store_types में प्रत्येक स्टोर type के स्टोर्स की संख्या गिनें.
  • store_types में प्रत्येक स्टोर type के स्टोर्स का proportion (अनुपात) गिनें.
  • store_depts में प्रत्येक department के स्टोर्स की संख्या गिनें, counts को descending order में sort करते हुए.
  • store_depts में प्रत्येक department के स्टोर्स का proportion (अनुपात) गिनें, proportions को descending order में sort करते हुए.

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

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

# Count the number of stores of each type
store_counts = ____
print(store_counts)

# Get the proportion of stores of each type
store_props = ____
print(store_props)

# Count the number of stores for each department and sort
dept_counts_sorted = ____
print(dept_counts_sorted)

# Get the proportion of stores in each department and sort
dept_props_sorted = ____.____(sort=____, normalize=____)
print(dept_props_sorted)
कोड संपादित करें और चलाएँ