Skip to content
Advertisement

How to replace rows which do not follow a specific schema-pattern? [closed]

I would like to delete all the rows that does not follow this pattern

JavaScript

My column is type(‘O’) and I would like to convert it into datetime, but unfortunately there are some rows which contain text. What I thought was to exclude all the rows which do no follow that pattern (using regex I would say w+-w+-w+sw+-w+-w+) and not digit.

However, it seems that the pattern above does work when applied to the column.

I would appreciated if you could tell me how to fix the pattern above in order to exclude (or just replace with null values) the rows not containing that schema.

Advertisement

Answer

Try .str.match:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement