Write a Pandas program convert the first and last character of each word to upper case in each word of a given series
- برمجة بايثون
- 2021-09-10
- mhanasmh00489829403
الأجوبة
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
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال