Skip to content

Tag: pandas

Divide multiple columns in pandas

I’m working with the following table: input_test input_test2 input_test3 ip_test ip_test2 ip_test3 ENSG00000000003.15 1 1 1 3 3 3 ENSG00000000457.14 2 2 2 1 1 1 ENSG00000000460.17 2 2 2 3 3 3 ENSG00000001036.14 3 3 3 4 4 4 ENSG00000001167.14 3 3 3 5 5 5 My goal is to make a new column called translation…

why does ~True not work in pandas dataframe conditional

I am trying to use switches to turn on and off conditionals in a pandas dataframe. The switches are just boolean variables that will be True or False. The problem is that ~True does not evaluate the same as False as I expected it to. Why does this not work? Answer This is a pandas operator behavior (implement…

extract value from a list of json in pyspark

I have a dataframe where a column is in the form of a list of json. I want to extract a specific value (score) from the column and create independent columns. I want to explode my result dataframe as: Answer Assuming you have your json looks like this You can read it, flatten it, then pivot it like so