Change language

Python | Pandas DatetimeIndex.day_name ()

|

DatetimeIndex.day_name() Pandas DatetimeIndex.day_name() returns DateTimeIndex day names with the specified locale ... The default is None, in which case names are returned in English.

Syntax: DatetimeIndex.day_name (locale = None)

Parameters:
locale: locale determining the language in which to return the day name

Return: Index of day names

Example # 1: Use DatetimeIndex.day_name () to return the day names for each entry in the DatetimeIndex object. Return day names in French

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex
# Here "Q" represents the quarterly frequency

didx = pd.DatetimeIndex (start = ’ 2018-11-15 09: 45: 10’ , freq = ’ Q’ , periods = 5 )

 
# Print DatetimeIndex

print (didx)

Output:

Now we want to return the day names in French.

# return day names in French

didx.day_name (locale = ’French’ )

Output:

As we can see from the output, the function returned an Index object containing titles days in French.

Let’s return the name of the days in English

# return day names in English

didx. day_name (locale = ’English’ )

Output:

Example # 2: Use DatetimeIndex.day_name () to return titles days for each entry in the DatetimeIndex object. Return day names in German

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex
# Here "M" represents the monthly frequency

didx = pd.DatetimeIndex (start = ’ 2015-03-02’ , freq = ’M ’ , periods = 5 )

  
# Print DatetimeIndex

print (didx)

Output:

Now we want to return the names of the days in German.

# return day names in German

didx.day_name (locale = ’German’ )

Output:

As we can see from the output, the function returned an Index object containing the day names in German.

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method