PYTHON LESSON 30 OF 32

Data analysis: ask better questions

Start with a question, inspect your data, clean missing values, then summarize. Never silently treat missing data as zero. Python’s standard library can calculate useful summaries; pandas helps with larger tabular workflows.

हिन्दी में समझें

पहले सवाल चुनें, डेटा देखें, गायब मान सँभालें, फिर सार निकालें। गायब डेटा को चुपचाप शून्य न मानें। मानक लाइब्रेरी सार निकाल सकती है; pandas बड़ी तालिकाओं में उपयोगी है।

अभ्यास: अंतिम बिक्री 210 से 240 करें; साफ डेटा का औसत 180 हो।

Hinglish mein samjhein

Pehle question chuno, data dekho, missing values handle karo, phir summary. Missing ko chupke se zero mat samjho. Standard library se summaries aur pandas se larger tables handle hote hain.

Practice: Last sale210 se240 karo; cleaned average180 hona chahiye.

A small Python example

sales = [120, 180, None, 210]
clean_sales = [x for x in sales if x is not None]
print("Total:", sum(clean_sales))
print("Average:", sum(clean_sales) / len(clean_sales))

The browser playground runs real Python with Pyodide. Use sample variables instead of interactive input(). Browser package support differs from desktop Python.

Try this example in the Python playground →

Practise this idea

Change the last sale from 210 to 240; the cleaned average should be 180.

Check answer & explanation
sales = [120, 180, None, 240]
clean_sales = [x for x in sales if x is not None]
print("Total:", sum(clean_sales))
print("Average:", sum(clean_sales) / len(clean_sales))

The comprehension removes None without treating it as zero. The remaining sales total 540 across three entries, giving an average of 180.

Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.

Check your understanding

What should happen before analysis?

  1. Inspect and clean data
  2. Ignore missing values
  3. Guess the result
Check the quiz answer

Inspect and clean data

Reliable summaries depend on understanding the input data.

References & corrections

Use the official Python documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.

FROM LEARNING TO BUSINESS RESULTS

Need a dashboard for your team?

Excel Keys designs custom Excel and HTML dashboards around your own KPIs and Excel files. They run offline in the browser, so your data stays on your computer.