Extract substring between two characters in pandas
10,178
As suggested in this answer https://stackoverflow.com/a/16842576/9754169 you can use the apply
approach
your_column.apply(lambda st: st[st.find("[")+1:st.find("]")])
Related videos on Youtube
Author by
Shyama Sonti
Updated on June 04, 2022Comments
-
Shyama Sonti almost 2 years
I have a column containing strings in this format:
/* [MCCOOK 0 ] */,999990,'MCCOOK 0 '
I want to extract the substring between [ and ] into another column. Please advise.
-
Yuca over 5 yearswhat have you tried so far?
-