0

I have a dataframe that is way bigger than it needs to be. Due to necessary transformations beforehand, I receive a dataframe looking like this:

A B C D E F
1.5 3 2 a 0 0
1.5 3 2 0 b 0
1.5 3 2 0 0 c

This is what it should look like afterwards:

A B C D E F
1.5 3 2 a b c

-----------------------------------------------------------------------------------

The second problem is that values are vertically listed, even though they could be next to each other. Example:

A1 A2 C
1.5 NA 2
1.5 NA 2
2.5 NA 2

Instead, I want this:

A1 A2 C
1.5 2.5 2
user438383
  • 5,716
  • 8
  • 28
  • 43
  • Are you using R or pandas? – Bashton Nov 09 '21 at 09:32
  • 1
    I am using R... –  Nov 09 '21 at 09:33
  • Does this answer your question? [How to combine duplicate rows in a data frame in R](https://stackoverflow.com/questions/41060599/how-to-combine-duplicate-rows-in-a-data-frame-in-r) – DeBARtha Nov 09 '21 at 09:38
  • This tackles the first problem, however not the second one but I am going to check it out, thanks –  Nov 09 '21 at 09:47
  • Why should A2 be equal to 2.5? – danlooo Nov 09 '21 at 10:45
  • Initially, I have multiple records for one user in a column but since I want to have one row per user, I want all his A-values in row, starting with A1 up until AX with X as the number of different values...I need to have a final dataframe where each row represents exactly one user. Don't get distracted by the column names (A1, A2, etc.), those are irrelevant placeholder names –  Nov 09 '21 at 10:48

0 Answers0