I have a sample dataframe df1
DateTime Values 2020-12-26 14:00:00 439.0 2020-12-26 14:00:00 441.0 2020-12-26 14:00:00 461.0 2020-12-27 08:00:00 536.0 2020-12-27 08:00:00 547.0 2020-12-27 08:00:00 484.0 2020-12-27 08:00:00 497.0 2020-12-27 14:00:00 491.0 2020-12-27 14:00:00 512.0 2020-12-27 14:00:00 529.0 2020-12-27 14:00:00 436.0
and another dataframe df 2
DateTime Trend 2020-12-18 14:00 no trend 2020-12-19 08:00 no trend 2020-12-19 14:00 no trend 2020-12-21 08:00 no trend 2020-12-21 14:00 no trend 2020-12-22 08:00 no trend 2020-12-22 14:00 decreasing 2020-12-23 08:00 no trend 2020-12-23 14:00 no trend 2020-12-24 08:00 no trend 2020-12-24 14:00 no trend 2020-12-25 08:00 no trend 2020-12-25 14:00 decreasing 2020-12-26 08:00 no trend 2020-12-26 14:00 decreasing 2020-12-27 08:00 no trend 2020-12-27 14:00 no trend
I am trying to create a new column df1[Trend] and assign the trend values based on the right date time
The result should be like this
DateTime Values Trend 2020-12-26 14:00:00 439.0 decreasing 2020-12-26 14:00:00 441.0 decreasing 2020-12-26 14:00:00 461.0 decreasing 2020-12-27 08:00:00 536.0 no trend 2020-12-27 08:00:00 547.0 no trend 2020-12-27 08:00:00 484.0 no trend 2020-12-27 08:00:00 497.0 no trend 2020-12-27 14:00:00 491.0 no trend 2020-12-27 14:00:00 512.0 no trend 2020-12-27 14:00:00 529.0 no trend 2020-12-27 14:00:00 436.0 no trend
Is there anyway I could it?
https://stackoverflow.com/questions/66848566/adding-column-with-values-from-one-dataframe-to-another-based-on-same-datetime March 29, 2021 at 11:55AM
没有评论:
发表评论