lower()
functionThe pandas lower()
function is used to convert all characters in a string to lowercase.
dataframe["columnname"][index].lower()
Note: You cannot apply the
lower()
function on the entire column of a DataFrame.
The following code shows how to use the lower()
function:
import pandas as pd# Create a DataFramedf = pd.DataFrame({"name": ["Maria","Paul","Eva","Oliver","Sebastian","Camila"],"age":[20,22,32,26,29,30],"salary":[2000,2500,4000,3500,4200,3000],"gender":["female","male","female","male","male","female"]})# Convert string to lowercase using lower()print(df["name"][4].lower())
In the code above:
Line 1: We import the pandas library.
Lines 4–10: We create a DataFrame, df
, from a dictionary.
Line 13: We use the lower()
function to convert the name at index in the name
column to lowercase.