df1=df.select_dtypes('object').applymap(lambda x:x.lower())
print(df1)
df是一个没有索引的,同一列上object,int都有的df
df1=df.select_dtypes('object').applymap(lambda x:x.lower())
print(df1)
df是一个没有索引的,同一列上object,int都有的df
同一列有object,有int,显然int是不能lower()的,可以先转一下,如下例:
import pandas as pd
df = pd.DataFrame({
'a': [1, 2] * 3,
'b': [True, False] * 3,
'c': [1.0, 2.0] * 3,
'd': ['1','2', 333, 23, 323, 52]
})
res = df.select_dtypes(include = ['object']).astype('str').applymap(lambda x: x.lower())
print(res)