Thank you for your continuous support.
when viewing data in Pandas.DataFrame such as display(df)
Some data are as follows:
I would like to do the following, but what should I do?
id
and date
are paired...id=C
and some records have both NaNs, or only one data exists
For the data frames listed in the question, the following is sufficient, but whether or not the data frames to be processed actually yield the desired results will probably be disappointing.
dfx=df.groupby(['id', 'date', group_keys=False)\
.apply(lambdax:x.bfill().ffill().drop_duplicates())\
.reset_index(drop=True)
print(dfx)
© 2024 OneMinuteCode. All rights reserved.