0

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']

1 Answer 1

1

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']

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.