Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Time Series Data wit | Master Data Science with Python lesso | BraveProgrammer
  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 27 of 60

·python

Time Series Data with Pandas

25 minutes

Course progress45%

Time Series with Pandas

Temporal data analysis is a core skill for finance, IoT, and many domains.

Converting strings to datetime

df['date'] = pd.to_datetime(df['date'])

Setting the datetime index

df_ts = df.set_index('date')
print(df_ts.head())

Resampling (e.g., daily to monthly)

monthly = df_ts.resample('M').sum()
print(monthly.head())

Rolling windows

# 7‑day moving average of a metric
df_ts['metric_ma7'] = df_ts['metric'].rolling(window=7).mean()

Time‑zone handling

df['date_utc'] = df['date'].dt.tz_localize('UTC')
df['date_est'] = df['date_utc'].dt.tz_convert('US/Eastern')

Frequency conversion and forward/backward fill

# Forward fill missing daily data
filled = df_ts.asfreq('D', method='ffill')

Info

Pandas leverages numpy.datetime64 under the hood, making date arithmetic fast.
Make it stickPractice what you've learned1 quiz · 4 practical tests · Optional activities from Master Data Science with PythonBrowse activities
Previous lessonPivot Tables and CrosstabulationsContinue to lesson 28Categorical Data and Encoding TechniquesBack to Master Data Science with Python curriculum