Get Month from Date in Pandas Last Updated : 30 May, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report When working with date columns in a dataset, you often need to extract just the month. This is simple using pandas.to_datetime() along with .dt.month or .dt.month_name(). Below are the most effective methods with examples and outputs.Using .dt.month to Get Numeric MonthThis is the most beginner-friendly method. It involves two steps:Convert string to datetime using pd.to_datetime().Extract month using .dt.month. Python import pandas as pd df = pd.DataFrame({'date': ['2020-01-18', '2020-02-20', '2020-03-21']}) df['month'] = pd.to_datetime(df['date']).dt.month print(df) Output date month 0 2020-01-18 1 1 2020-02-20 2 2 2020-03-21 3 Explanation: .dt.month returns the month component as integers (1 for january, 2 for february, etc.)Using .month on a DatetimeIndexIf you're working with a DatetimeIndex, you can directly use .month to get the integer month values. Python import pandas as pd dti = pd.date_range('2020-07-01', periods=4, freq='ME') print(dti.month) OutputIndex([7, 8, 9, 10], dtype='int32') Explanation: .month extracts the integer month directly from the index.Examples of Extracting Months in PandasExample 1 : Extracting Month Integers in a DataFrameUse .dt.month to get the numeric month from a datetime range. Python import pandas as pd df = pd.DataFrame({ 'date_given': pd.date_range('2020-07-01 12:00:00', periods=5) }) df['month_of_date'] = df['date_given'].dt.month print(df) Output:Example 2: Extracting Full Month Names Using .dt.month_name()Use .dt.month_name() to get readable month names instead of numbers. Python import pandas as pd d = ['14 / 05 / 2017', '2017', '07 / 09 / 2017'] frame = pd.DataFrame({ 'date': pd.to_datetime(d, format='mixed', dayfirst=True) }) frame['month'] = frame['date'].dt.month_name() print(frame) Output:.dt.month_name() Comment More infoAdvertise with us Next Article Get Day from date in Pandas - Python J jainanjali733985 Follow Improve Article Tags : Pandas Python-pandas Python pandas-dataFrame python AI-ML-DS With Python +1 More Practice Tags : python Similar Reads Get month and Year from Date in Pandas - Python Pandas is one of the most powerful library in Python which is used for high performance and speed of calculation. It is basically an open-source BSD-licensed Python library. Commonly it is used for exploratory data analysis, machine learning, data visualization in data science, and many more. It has 4 min read Get the day from a date in Pandas Given a particular date, it is possible to obtain the day of the week on which the date falls. This is achieved with the help of Pandas library and the to_datetime() method present in pandas. In most of the datasets the Date column appears to be of the data type String, which definitely isn't comfor 2 min read Get Day from date in Pandas - Python Let's discuss how to get the day from the date in Pandas. There can be various ways for doing the same. Let's go through them with the help of examples for better understanding. Example 1 : Pandas.dt_range takes input as a range of dates and returns a fixed frequency DatetimeIndex. Series.dt.dayofwe 2 min read Max and Min date in Pandas GroupBy Prerequisites: Pandas Pandas GroupBy is very powerful function. This function is capable of splitting a dataset into various groups for analysis. Syntax: dataframe.groupby([column names]) Along with groupby function we can use agg() function of pandas library. Agg() function aggregates the data tha 1 min read Pandas Series dt.day_name() Method | Get Day From Date in Pandas Pandas dt.day_name() method returns the day names of the DateTime Series objects with specified locale. Example Python3 import pandas as pd sr = pd.Series(['2012-12-31 08:45', '2019-1-1 12:30', '2008-02-2 10:30', '2010-1-1 09:25', '2019-12-31 00:00']) idx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 2 min read Get Minutes from timestamp in Pandas-Python Pandas is an open-source library built for Python language. It offers various data structures and operations for manipulating numerical data and time series. Here, let's use some methods provided by pandas to extract the minute's value from a timestamp. Method 1: Use of pandas.Timestamp.minute attri 3 min read Like