Skip to content
Advertisement

Creating new columns from the values of another column

I have a column in a dataframe with different strings.

JavaScript

What I want to do is to create new columns, IP Address and MAC Address with the corresponding values from the column above.

So that the expected output looks like this:

JavaScript

The problem is, that I cannot deal with the rows that does not contain IP and MAC. I tried splitting using np.where as well as finding partial matches but didn’t succeed.

Advertisement

Answer

Idea is use list comprehension with filtering if not missing value or None and exist , and =, pass to DataFrame constructor and last use DataFrame.join to original:

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