7

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.

Shyama Sonti
  • 321
  • 1
  • 5
  • 16

1 Answers1

13

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("]")])
Yuca
  • 6,010
  • 3
  • 22
  • 42