I have a dataframe like the following:
| int_col_1 || int_col2 || str_col3 || float_col4 || float_col5 |
|---------------||--------------||--------------||----------------||----------------|
| 123 || 456 || potato || 0.1 || -0.2 |
| 456 || 456 || potato || 0.1 || 5.0 |
| 456 || 456 || potato || 0.1 || -0.2 |
| ... || ... || ... || ... || ... |
I want to sum all float_col_4 and float_col5 rows that are above 0 per different int_col_1 and append the result as a new row.
So the new dataframe would look like this.
| int_col_1 || int_col2 || str_col3 || float_col4 || float_col5 |
|---------------||--------------||--------------||----------------||----------------|
| 123 || 789 || potato || 0.1 || -0.2 |
| Total || NULL || NULL || 0.1 || 0.0 |
| 456 || 734 || potato || 0.1 || 5.0 |
| 456 || 423 || potato || 0.1 || -0.2 |
| Total || NULL || NULL || 0.2 || 5.0 |
| ... || ... || ... || ... || ... |
How can I do this? I need that to be appended to the same dataframe for simplicity so I guess I will also have to cast the first column from int to str, or drop the "Total" to the str_col3?
Thanks!