Thanks in advance, I have been struggling with this for a couple of hours now. I have a column named 'CaseNumber'. the data in that column is structured as 'Case ID Number - 00123456'.

I am trying to create a loop that will go through the entire sheet and strip 'Case ID Number - 00'. So the final output would just be the 6 digit number set.

So far I have found the attribute .strip('Case ID Number - 00') but I cannot find the logic to create the for loop.

I appreciate any insight.


String operations on particular columns (or series) can be done by appending .str to the series. You can use the following command to get your output:

>>> df['Case Number'].str.strip('Case ID Number - 00')

You can refer to the documentation here Working with text.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.