Skip to content

Tag: pandas

Extracting features from dataframe

I have pandas dataframe like this For example if “ex” start to 533,535,545 new variable should be : Sample output : How can i do that ? Answer You can use np.where: Update You can also use your Phone column directly: Note: If Phone column contains strings you can safely remove .astype(str).

Rename a row with X unknown characters

If I have the following dataframe: ID other 219218 34 823#32 47 unknown 42 8#3#32 32 1#3#5# 97 6#3### 27 I want to obtain the following result: ID other 219218 34 823#32 47 unknown 42 8#3#32 32 unknown 97 unknown 27 I am using the following code which works. Is there a way to make it more optimal, bearing in

python convert single json column to multiple columns

I have a data frame with one json column and I want to split them into multiple columns. Here is a df I’ve got. I want the output as below: I’ve tried Both didn’t work. can someone please tell me how to get output that I want? Answer One way using pandas.DataFrame.explode: Output: