Skip to content
Advertisement

Extracting features from dataframe

I have pandas dataframe like this

JavaScript

For example if “ex” start to 533,535,545 new variable should be :

Sample output :

JavaScript

How can i do that ?

Advertisement

Answer

You can use np.where:

JavaScript

Update

You can also use your Phone column directly:

JavaScript

Note: If Phone column contains strings you can safely remove .astype(str).

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