Linked Questions

Popular Questions

Reverse pandas string / reverse extract pandas DF

Asked by At

Good day,

I got files with path in column thus:

pd.DataFrame({'path':[
'C:/some_1_path/file_1.zip',
'C:/some_1_path/file_2.zip']

I wish to extract the pattern _\d from this like this:

'C:/some_1_path/file_1.zip'| '_1' 
'C:/some_1_path/file_2.zip'| '_2'

Since the _1 happens to be in path .str.extract() picks that one. extractall will work , but requires extra steps.

How would one do .str.extract(pattern) in reverse order? I could reverse the string but extra steps and all that.

Related Questions