Skip to content

Tag: dataframe

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

pandas groupby ignoring column

Below is my groupby function and dataset before the operation. However, the statement as written produces no change. I want this to be a single row containing sums for each category. Answer You need to enclose your list by []:

Pandas pivot table count

I would like to ask a question concerning pivot tables in Pandas. I have been trying to make a pivot table for this kind of table: sector score US null US null US 1 EU null EU 2 EU 2 EU 4 UK null UK null UK null UK 4 UK 4 Eventually, I would like this table to be

Remove duplicate substring at the start of the string

I would like to remomve duplicate substrings at the start of a string where a duplicate exists. I sort of have the logic working for the first row (see below) but am quite new to Python so am struggling to produce code which will apply the same logic for a rows in a larger dataset. Below is an example of: