import pandas as pd
series1 = pd.Series(['php', 'python', 'java', 'c#'])
print("Original Series:")
print(series1)
result = series1.map(lambda x: x[0].upper() + x[1:-1] + x[-1].upper())
print("\nFirst and last character of each word to upper case:")
print(result)
Sample Output:
Original Series:
0 php
1 python
2 java
3 c#
dtype: object
First and last character of each word to upper case:
0 PhP
1 PythoN
2 JavA
3 C#
dtype: object
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer