【问题标题】:Combine rows from two datasets if the have an identical time, python如果两个数据集的时间相同,则合并来自两个数据集的行,python
【发布时间】:2019-03-05 13:44:19
【问题描述】:

我有两个数据集,一个名为“chekan”大小(86352,6)的数组和一个名为“nav_reduceed_df”大小(260757,10)的数据框。正如您在图中看到的,我的数据有时间戳。我想找到所有具有相同时间的行,并将其放入输出数组/数据框中。从时间和日期我计算出两个数据集的十进制日期(doy),它是 cehkan 数组中的第 6 列,以及数据框中的第 10 列(deciJday)。 (请注意,图中并未显示所有小数)。 .

如果在两个数据集中找到相同的时间,我需要它给我输出(行时间(doy),来自 chekan-array 中第 4 列的行值,来自 nav_reduceed_df 的行 lat,来自 nav_reduceed_df 的行 lon)

谁能帮忙?

【问题讨论】:

    标签: python arrays dataframe find element


    【解决方案1】:

    所以让我先将 numpy 数组转换为数据帧..

    import pandas as pd
    import numpy as np
    df_newdata=pd.DataFrame(data=chekan,columns=['d','h','m','s','a','decimal_day'])
    df_merge=pd.merge(left_on='decimal_day',right_on='deciJday',how='inner')
    df_merge[[give all the columns that you want here]]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多