Python · Visualization
Create a bar chart from frequencies
Work with the mini survey and compare your output with the expected result.
Mini exercises · Practice with data ↓
Try it in three steps
- Extract the mini exercise package below. Complete the cleaning task or use anket-temiz.csv. Requires pandas and matplotlib.
- Work in the data folder and load the data: import pandas as pd; df = pd.read_csv("anket-temiz.csv"); import matplotlib.pyplot as plt
- Run: df["transport"].value_counts().reindex(["bus", "walk", "bike"]).plot.bar(); plt.ylabel("Participants"); plt.ylim(0, 12); plt.tight_layout(); plt.show()
How to read the output
bus=10, walk=6, bike=4. The vertical axis counts participants; percentages are 50%, 30%, 20%.
Test your understanding.
True or false?
These synthetic data establish conclusions about a real population.
Related concepts
Official source
Python · Documentation ↗Documentation checked: . Steps are based on official documentation and have not been tested in the application. Menu names may differ by version and interface language.