I have problem which is similar to this post https://stackoverflow.com/questions/45086369/assign-unique-id-to-each-unique-value-in-group-after-pandas-groupby However, one of the column to groupby is Timestamp and its giving me weird output as follows:
from pandas import Timestamp
df=pd.DataFrame({'day': [Timestamp('2017-03-27'),
Timestamp('2017-03-27'),Timestamp('2017-04-01'),
Timestamp('2017-04-03'),Timestamp('2017-04-06'),
Timestamp('2017-04-07'),Timestamp('2017-04-11'),
Timestamp('2017-05-01'),Timestamp('2017-05-01')],
'act_id': ['916298883','916298883','916298883','926539428','930641527',
'930641527','930641527','966163233','966163233']})
I did this:
df['no_adm'] = df.groupby('act_id')['day'].transform(lambda x: pd.factorize(x)[0]+1)
and it gave me:
I have no idea how the 1970-01-01 00:00:00.0000000000 came from and to remove it. I just want my dataframe without those timestamp element in no_adm column.