Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Data Foundations · A little practice goes a long way.

← Visualise lessonsTINY TABLES · REAL PYTHON · YOUR PACE
Choose and build · VR1 · 12 MIN

Review · Choose and build

Task 1 · Retrieve and combine

Exercises within this concept

  1. Task 1Retrieve and combineCurrent exercise
  2. Task 2Retrieve and combine
  3. Task 3Retrieve and combine
Task 1 · Movie night

Using df, a cinema wants to see which genres occur most often.

The editable setup on the right creates df. Run executes the setup and your work from top to bottom.

Your requirements

  1. Choose "scatter", "histogram", "counts" or "line".
  2. Write the choice as a Python string.

Your inputs

Movie night · 6 synthetic rows
moviegenreminutesratingscreen
MoonDrama903.7One
RiverComedy1054.2One
SparkDrama1124.8Two
StoneAction984Two
MapComedy853.9One
CloudAction1204.5Two

Revisit the concept lesson →

Remember the idea

Concept sketch: bar height = number of rowsCount04A2B3Cbar height = number of rows

Choose a chart from the question and the types of data. Decide what each mark should represent before writing plotting code.

A small example

“Do longer study times go with higher scores?” compares two measurements per person, so one point per person is useful.

What each choice does
Code or choiceMeaning
"scatter"Relationship between two numeric measurements.
"histogram"Distribution of one numeric measurement.
"counts"Frequency of category labels.
"line"Change along an ordered sequence such as time.
Hint

Genres are categories; the question asks about their frequencies.

Reveal solution

One way to do it. Keep any supplied setup in the editor and use this in the Your work section.

"counts"
Your task · Task 1
  1. Using df, a cinema wants to see which genres occur most often.
  2. Choose "scatter", "histogram", "counts" or "line".
  3. Write the choice as a Python string.

Tab: indent · Shift+Tab: outdent · Esc, then Tab: leave editor

Edit Python. Control or Command plus Enter runs it. Tab indents by four spaces. Shift plus Tab outdents. Press Escape, then Tab or Shift plus Tab to leave the editor.

Each run executes all editor code in a fresh Python session. Display a value by leaving it on the final line.

Python starts when you open a lesson.

Output

Run your code to see what Python returns.