0
  • This post was edited.

I am a R user that is trying to transition to python. I need the concatenate the inout variable by ID but I want to keep all records (not collapse my data). In R there is an ungroup option you can add after aggregating your data.

    ID  inout       desire_var
0  120     IN          IN-IN-OUT
1  120     IN          IN-IN-OUT
2  120     OUT         IN-IN-OUT
import pandas 
df = pandas.DataFrame({'ID': [120, 120, 120], 
                   'inout': ['IN', 'IN', 'OUT'],
                   'desire_var' : ['IN-IN-OUT', 'IN-IN-OUT', 'IN-IN-OUT']})
mar355
  • 155
  • 9

0 Answers0