Skip to main content
  1. About
  2. For Teams
Asked
Viewed 30 times
0

Guys i would like slice the column 'Delivey' in pandas line by line. How i do that?

Actual Data:

OF Delivery
BR1000 888000; 888001
BR1002 888002; 888003
BR1003 88804

New data:

OF Delivery
BR1000 888000
BR1000 888001
BR1002 888002
BR1002 888003
BR1003 88804

Thanks, Regards

1 Answer 1

2

Use str.split:

>>> df.assign(Delivery=df['Delivery'].str.split('; ')).explode('Delivery')
       OF Delivery
0  BR1000   888000
0  BR1000   888001
1  BR1002   888002
1  BR1002   888003
2  BR1003    88804
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Post as a guest

Required, but never shown

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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.