Pandas
Pandas (18)
알 수 없는 사용자
2022. 8. 9. 22:08
728x90
How to convert the first character of each element in a series to uppercase?
# Input
ser = pd.Series(['how', 'to', 'kick', 'ass?'])
# 1
ser.map(lambda x: x.title())
# 2
ser.map(lambda x: x[0].upper() + x[1:])
# 3
pd.Series([i.title() for i in ser])
# output
0 How
1 To
2 Kick
3 Ass?
dtype: object