Author : MD TAREQ HASSAN
Population graph using Matplotlib
- Get data: Japan population csv
- Read sample population data from csv file and plots it using Matplotlib
basic-analysis.ipynb
import pandas as pd
import matplotlib.pyplot as plt
# Prepare dataframe
df = pd.read_csv('../data/japan-population.csv')
x = df['year']
y = df['population']
# Plot graph
plt.title("Population of Japan")
plt.xlabel('Year')
plt.ylabel('Population')
plt.plot(x,y)
plt.show()
Value counts
- Counts unique values
- Returns a object containing counts of unique values
- Syntax:
df.SeriesName.value_counts()
- The first value is the most frequently occurring element. The second, the second most frequently occurring element and so on
- By default, drop any is true. To set false:
.value_counts(..., dropna=False)
import pandas as pd
df = pd.read_csv("olympics.csv", skiprows=4)
df.Edition.value_counts()
df.Gender.value_counts()