Skip to content

Tag: pandas

summing the values row wise

I have a three column of data as arranged below: Input file: In the above input file the first column values are repeated so I want to take only once that value and want to sum the third column values row wise and do not want to take any second column values. I also want to append a third column

Read CSV file with Python function

I’m trying to write my read/write function to a csv, but it can’t return any value. I’m reading from a CSV, replacing the ” ; ” in the second column with ” ” and performing and saving the csv already handled. But for some reason it doesn’t save my csv, is my fun…

pandas: Explode (duplicate) by group

I have a df that looks like this : It’s an example for one row but there are thousands of rows. I want to explode each value where there are multiple values in these four “TEST” columns ie. I want each one to duplicate the row for each one of the “test” that is the same and if th…

Get the last day of a year

I have a pandas df with a year column. I want to get the last day of that year. For example: 2020 –> 2020/12/31 I tried: but I get this error: “cannot convert the series to <class ‘int’> ” What am I doing wrong? Thanks PS I realized I could just do: but I’m still w…