0

I have been able to find the code for almost what I want to do but not exactly. I would like to turn this table into...

Unit_id     DATE            PART
ASF-400     3/4/2018        PE
SDO-130     5/4/2019        PE
ASX-124     1/16/2019       TR
ARR-443     12/11/2018      EN
NLD-434     2/14/2019       PE
FDD-653     5/27/2019       TR
continues....

...this:

Unit_id     PE          TR          EN
ASF-400     3/4/2018    1/10/2020   1/4/2020
SDO-130     5/4/2019    8/6/2019    7/3/2019
ASX-124     7/16/2018   1/16/2019   11/17/2018
ARR-443     4/15/2019   10/1/2019   12/11/2018
NLD-434     2/14/2019   2/7/2019    4/3/2018
FDD-653     5/7/2019    5/27/2019   3/14/2019

I believe it has something to do with the Pandas Groupby function but I can't figure it out.

Thank you in advance!

adrian
  • 148
  • 8
  • Could you explain better the output result please? what do they new dates mean? – Ivan Jan 29 '20 at 21:26
  • The new dates are the same as from the original dataframe (I just didn't copy it fully) For example ASF-400 has the PE date of 3/4/2018 – adrian Jan 29 '20 at 21:28
  • can you test `pd.crosstab(df.Unit_id, df.PART, df.DATE, aggfunc=lambda x: x)` i don't understand what you do with null values but it seems ur output doesn't match ur original df. – Umar.H Jan 29 '20 at 21:30

0 Answers0