I have a dataframe with a columns that contains strings and i want to slice it from second space to 4th space. In general, in a column of strings, How do i 1. find the indices of nth occurance of a substring 2. subset the strings according to these indices
I am looking for a solution without involving regexes
Try:
df['column'].str.split().str[2:4].str.join(' ')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With