I'm trying to search some post related to remove substring key but unfortunately those solutions don't work in my case.
Could you help me ?
Input:
['Female/Fri', 'Male/Fri', 'Female/Sat', 'Male/Sat', 'Female/Sun','Male/Sun', 'Female/Thur', 'Male/Thur', 'Female', 'Male']
Output
['Fri', 'Fri', 'Sat', 'Sat', 'Sun','Sun', 'Thur', 'Thur', 'Female', 'Male']
CodePudding user response:
You don't even need pandas for that. A simple list comprehension should be enough
In [3]: [s.split('/')[-1] for s in ['Female/Fri', 'Male/Fri', 'Female/Sat', 'Male/Sat', 'Female/Sun','Male/Sun', 'Female/Thur', 'Male/Thur', 'Female', 'Male']]
Out[3]: ['Fri', 'Fri', 'Sat', 'Sat', 'Sun', 'Sun', 'Thur', 'Thur', 'Female', 'Male']