Python pandas: remove everything after a delimiter in a string

前端 未结 4 736
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 03:00

I have data frames which contain e.g.:

"vendor a::ProductA"
"vendor b::ProductA"
"vendor a::Productb"

I need to

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 03:38

    You can use str.replace(":", " ") to remove the "::". To split, you need to specify the character you want to split into: str.split(" ")

    The trim function is called strip in python: str.strip()

    Also, you can do str[:7] to get just "vendor x" in your strings.

    Good luck

提交回复
热议问题