I want to convert index values of a pandas dataframe to lowercase. Please use this to test:
import pandas as pd
df = pd.DataFrame([1, 2, 3], columns = ['c'], index = ['A','B','C'])
lower() . Converts all characters to lowercase.
Select the column you need to make the values capital or lowercase, and then click Kutools > Text > Change Case.
str. lower() and df["x"] = df["x"]. str. lower() .
You can use the vectorised str
method lower
:
In [115]:
df.index = df.index.str.lower()
df
Out[115]:
c
a 1
b 2
c 3
EDIT
For versions older than 0.16.1
(thanks to @Joris for pointing that out) you can call map
and pass the str.lower
function:
In [117]:
df.index = df.index.map(str.lower)
df
Out[117]:
c
a 1
b 2
c 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With