Skip to content
Kola1
Load the dataset and assign it to the variable 'nnewi'
import pandas as pd
# Load the dataset
# Ensure the file path is correct. If the file is in the same directory as the script, just use the filename.
# Otherwise, provide the full path to the file.
nnewi = pd.read_csv("./children_in_nnewi.csv")Print the first 5 rows of the dataset
print(nnewi.head(5))Determine the dimensions of the 'nnewi' dataframe (rows, columns)
print(nnewi.shape)What is the mean age of the children resident in nnewi?
mean_age = nnewi['age'].mean()
print(mean_age)What is the age range of the children in nnewi?
min_age = nnewi['age'].min()
max_age = nnewi['age'].max()
print("Age range:", min_age, "-", max_age)"Proportion of childreen of each town"
# Calculate frequencies
town_freq = nnewi['town'].value_counts()
# Calculate percentages
town_pct = nnewi['town'].value_counts(normalize=True) * 100
# Create a DataFrame to display the results
town_stats = pd.DataFrame({'Frequency': town_freq, 'Percentage': town_pct})
print(town_stats)
Calculate the count of boys and girls in the dataset
gender_counts = nnewi['gender'].value_counts()
print(gender_counts)