【问题标题】:merge two different excels based on two conditions根据两个条件合并两个不同的excel
【发布时间】:2022-08-19 02:06:21
【问题描述】:

我有两个擅长。第一个是因变量:数据与日期&站号, 日期为数据帧的“索引”,标头为站 ID。如下图所示, 第二个(自变量)是我用来模拟因变量的数据(上面的第一个excel),也有日期,格式为一列表示年份,另外两列分别表示月份和日期。如下图所示

我想要的是 1. 跳过第一个 excel 中的 NaN 值。 2.将第一个表中的值添加到第二个基于excel的在同一天同一个水质监测站ID这些是我到现在为止写的代码,我是 python 新手,已经苦苦挣扎了好几天。

import csv
import pandas
import pandas as pd
import openpyxl
from numpy import size
from pandas import DataFrame
from datetime import datetime
import datetime as dt
import numpy as np
# firstly, exclude those don\'t have value
# read csv file(2)
csvB4reflectance = pd.read_csv(\'GEEdownload.csv\')
b4 = pd.read_csv(\'GEEdownload.csv\',sep=\',\',parse_dates=[\'system:time_start\'])
b4.set_index(\'system:time_start\',inplace=True) #set index and change index type, to drop out
print(csvB4reflectance)
path = \'F:/72hourtimewindow/project/waterqualitydate/29UMT/\'
excelorder = pd.read_excel(path+\'Stationwithorder.xls\',header = 0, index_col=0)
print(excelorder)
b41 = b4.dropna(axis=0,how=\'all\')
print(b41)
# process this table, start to calculate when data in the form is not NaN
b41num = b41.to_numpy()
print(b41num)
# import excel order
for i in b41num:
    for j in i:
        if j == NaN:
            break
        else:
            if 
     print(j)```

    标签: python for-loop if-statement indexing merge


    【解决方案1】:

    我也遇到过这个问题,需要先把第二张图融化!~然后一切似乎都好了

    【讨论】:

      猜你喜欢
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      相关资源
      最近更新 更多