Lesson 1 · Python For Time Series
01 Introduction to Python in Jupyter Notebook
In this lesson, we will learn how to use Python in Jupyter Notebooks, explore basic syntax, and work on a simple project. No experience required. All steps…
- CoursePython For Time Series
- Lesson1 of 30
- Video11 min
- FormatJupyter notebook · 20 code cells
What you'll learn
Data
No separate download needed — the notebook creates or downloads everything it uses.
📓 Full notebook
Download .ipynb
Welcome to Python Jupyter Notebook Setup!#
In this lesson, we will learn how to use Python in Jupyter Notebooks, explore basic syntax, and work on a simple project.
No experience required. All steps are explained for beginners.
What is a Jupyter Notebook?#
Jupyter Notebooks let you write and run code in small pieces, called 'cells'. They are great for learning, exploring, and sharing Python code.
You can add notes with text or use code cells to try things out.
# Before we begin, let us silence any warning messages.
import warnings
warnings.filterwarnings("ignore")
# Let us check Python's version. Notebooks often show the version being used.
import sys
print("Python version:", sys.version)
# Let us try a simple print statement to see how output works.
print("Hello, world!")
Code Cells and Text Cells#
In Jupyter, there are two main cell types:
- Code cells: where you write and run Python code
- Markdown cells: for explanations, like this one
You run a cell by clicking inside it and pressing Shift+Enter.
# Let us assign our first variable.
name = "Alice"
print("Nice to meet you,", name)
# Variables can be numbers too.
x = 3
y = 7
sum_xy = x + y
print("The sum is:", sum_xy)
# Let us try inputting your name yourself.
your_name = input("What is your name? ")
print("Hello,", your_name)
Data Setup#
Let us load a small real-world dataset. We will use airline passenger numbers as an example. This time series data is popular for learning.
# Download and look at the airline passengers dataset.
import pandas as pd
url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csv"
df = pd.read_csv(url)
print("Shape of data:", df.shape)
df.head()
# Let us make a quick plot of the data.
import matplotlib.pyplot as plt
plt.figure(figsize=(10,4))
plt.plot(df['Month'], df['Passengers'])
plt.xlabel('Month')
plt.ylabel('Number of Passengers')
plt.title('Airline Passengers Over Time')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Try Making Your Own Data Table#
You can make a small table, called a dataframe, from a Python dictionary.
Here is a quick example.
# Make a dataframe from scratch.
sample_data = {
"Name": ["Ava", "Ben", "Chloe"],
"Score": [88, 92, 75]
}
df2 = pd.DataFrame(sample_data)
print("Sample table:")
df2
# Select just one column: the names.
names_column = df2["Name"]
print("Names:", list(names_column))
# Add a new column to our small table.
df2["Passed"] = df2["Score"] >= 80
print(df2)
# Remove a column from the table.
df2 = df2.drop("Passed", axis=1)
print(df2)
# Basic error: try to access a column that does not exist.
try:
print(df2["Grade"])
except KeyError as e:
print("Oops! Column not found:", e)
# Sort the table by score from highest to lowest.
df_sorted = df2.sort_values(by="Score", ascending=False)
print(df_sorted)
# Filter the table: show only scores above 80.
passed_students = df2[df2["Score"] > 80]
print(passed_students)
# Loop through the names in the table and greet each person.
for n in df2["Name"]:
print("Hello,", n)
# Challenge: Add a new row to the table using user input.
new_name = input("Enter a new student's name: ")
new_score = int(input("Enter the new score: "))
df2 = pd.concat([df2, pd.DataFrame({"Name": [new_name], "Score": [new_score]})], ignore_index=True)
print(df2)
Recap#
- We learned how to print messages, work with variables, and ask for input.
- We loaded and looked at real data.
- We made a small table and practiced sorting, filtering, and updating rows.
You can now use Jupyter Notebooks to explore Python and try new ideas.
Want more practice or ideas?#
- Try creating your own small table about friends or pets.
- Add a column for birthday months or favorite colors.
- Try sorting or filtering by new rules.
If you enjoyed this video, be sure to like and subscribe for more beginner-friendly tutorials.
Happy coding!
Found this useful?
All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.



