ai-data-analysis-guided-tour

piotrek / ai-data-analysis-guided-tour

Load the Air Passengers sample dataset from https://raw.githubusercontent.com/pplonski/datasets-for-start/master/air-passengers/AirPassengers.csv. Calculate summary statistics and overall passenger growth, create a monthly passenger trend chart, and explain three important findings in beginner-friendly language.

I’ll start by loading the dataset and doing the required first inspection so we can confirm the structure before calculating statistics and plotting.

</>Load air passengers data
import pandas as pd
from IPython.display import display

url = "https://raw.githubusercontent.com/pplonski/datasets-for-start/master/air-passengers/AirPassengers.csv"
df = pd.read_csv(url)

print(f"Shape: {df.shape}")
columns = df.columns.tolist()
print(f"Columns ({len(columns)}):", columns if len(columns) <= 100 else columns[:100] + ["..."])

display(df.head())

df
Shape: (144, 2)
Columns (2): ['Month', '#Passengers']
Month #Passengers
0 1949-01 112
1 1949-02 118
2 1949-03 132
3 1949-04 129
4 1949-05 121
Month #Passengers
0 1949-01 112
1 1949-02 118
2 1949-03 132
3 1949-04 129
4 1949-05 121
... ... ...
139 1960-08 606
140 1960-09 508
141 1960-10 461
142 1960-11 390
143 1960-12 432

144 rows × 2 columns

Thinking

Deciding on paths

I need to decide between Path A and Path B. The current outputs only cover schema and heads, but to meet our goal, we need summary statistics, overall growth data, a monthly trend chart, and to explain those findings. Path B seems better because we need to provide brief insights along with runnable Python code to gather the missing data. Even though the instructions emphasize keeping one primary objective, it might be feasible to combine calculating stats and generating the chart into a single code block for this evidence-gathering step.Preparing analysis code

I need to fulfill the goal by analyzing the time series data all at once. I'll create minimal runnable code to convert the month to datetime, compute summary statistics, overall growth in passenger counts in both absolute and percentage terms, and plot the monthly trend. A compact summary text may also help. Since the user is likely looking to analyze the latest outputs, I’ll focus on the code and ensure I include concise insights: 144 monthly rows, probably from January 1949 to December 1960, capturing the #Passengers measure. I’ll aim for a single code block, ending with either ax or plt.show() based on what’s expected in a notebook environment.Crafting display code

I'm planning to display tables sequentially for better clarity. Since the initial inspection rules are already addressed, I'll focus on using seaborn or matplotlib for visual representations. I might use display(summary_stats.to_frame(name="value")) to show actual data, which seems appropriate. For inspecting the DataFrame, I’ll only present the shape and columns as text. I also need to print the growth data and create a chart with labels. Let’s create minimal code to achieve this efficiently!

The current output already shows the key structure: one monthly date column and one passenger-count column across 144 rows, which is enough to treat this as a monthly time series.

</>Plot passenger trend
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from IPython.display import display

df["Month"] = pd.to_datetime(df["Month"])

summary_stats = df["#Passengers"].describe()
start_passengers = df["#Passengers"].iloc[0]
end_passengers = df["#Passengers"].iloc[-1]
growth_abs = end_passengers - start_passengers
growth_pct = growth_abs / start_passengers * 100

display(summary_stats.to_frame(name="value"))

print(f"First month: {df['Month'].min().strftime('%Y-%m')}")
print(f"Last month: {df['Month'].max().strftime('%Y-%m')}")
print(f"Passengers in first month: {start_passengers}")
print(f"Passengers in last month: {end_passengers}")
print(f"Overall growth: {growth_abs} passengers")
print(f"Overall growth rate: {growth_pct:.2f}%")

plt.figure(figsize=(12, 5))
sns.lineplot(data=df, x="Month", y="#Passengers")
plt.title("Monthly Air Passengers Trend")
plt.xlabel("Month")
plt.ylabel("Number of Passengers")
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Notebook output
Thinking

Thinking...

Made with MLJAR
Explore more conversationsMore from piotrek