I am trying to use the spread function in dplyr to "flatten" a table but it does not appear to be working as intended.

Example table:

enter image description here

I am trying to flatten this one so that each Record Number is appearing on one line only, so end result would be as follows:

enter image description here

This seems like it should be a no-brainer with spread with code as follows:

spread(dt, key = 'Record Type', value = 'Status')

but what I am ending up with is still multiple lines per Record Number:

enter image description here

Not understanding why this is not properly flattening out by the Record Number? Any clues? Also, any more recommended method to flatten data tables in Python (Pandas)?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.