Pandas 合并导致Int值错误的数据帧

Pandas 合并导致Int值错误的数据帧,pandas,merge,int,Pandas,Merge,Int,我先道歉,因为我对编程、Python和Pandas还不熟悉。我正在尝试基于日期时间索引并使用外部联接,逐步合并五个数据帧。该数据是我在以下链接中附加的水位测量站数据:。这些数据来自加拿大和美国的各种水位测量站系统,除了链路中的美国数据必须通过简单地减去站的高程而简化为基准外,其他数据都相当相似。我已经将美国电台添加到他们自己的模块中来处理处理。合并工作正常,除非合并处理后的美国数据时抛出以下错误: ValueError: can not merge DataFrame with instance

我先道歉,因为我对编程、Python和Pandas还不熟悉。我正在尝试基于日期时间索引并使用外部联接,逐步合并五个数据帧。该数据是我在以下链接中附加的水位测量站数据:。这些数据来自加拿大和美国的各种水位测量站系统,除了链路中的美国数据必须通过简单地减去站的高程而简化为基准外,其他数据都相当相似。我已经将美国电台添加到他们自己的模块中来处理处理。合并工作正常,除非合并处理后的美国数据时抛出以下错误:

ValueError: can not merge DataFrame with instance of type <type 'int'>

您在哪一行收到此错误?抱歉,刚才注意到我在代码示例中包含了错误的合并,但我在final13771=pd上收到了错误。merge(final13771,noaaDF[“9052030”]、how='outer',left_index=True,right_index=True)每一个错误的线性
noaaDF[“9052030”
只是一个整数,所以你不能把它和数据框合并。非常感谢Vishal!刚从你的评论中意识到我做了什么。愚蠢的初学者错误。在哪一行出现此错误?抱歉,刚刚注意到我在代码示例中包含了错误的合并,但我在final13771=pd上出现了错误。merge(final13771,noaaDF[“9052030”]、how='outer',left_index=True,right_index=True)每一个错误的线性
noaaDF[“9052030”
只是一个整数,所以你不能把它和数据框合并。非常感谢Vishal!刚从你的评论中意识到我做了什么。愚蠢的初学者错误。
noaaDFs = {}

filenames = glob.glob(r"C:\Users\Andrew\Documents\CHS\SeasonalGaugeAnalysis\Input\CO-OPS_*_wl.csv")

dataframes = [pd.read_csv(filename) for filename in filenames]


for df, filename in zip(dataframes, filenames):
    df['filename'] = os.path.basename(filename)
    df['Station ID'] = df['filename'].str[7:14]
    del df['filename']

combined_df = pd.concat(dataframes, ignore_index=True)

df = pd.DataFrame.from_records(combined_df)

df['Date Time (UTC)'] = pd.to_datetime(df['Date'] + ' ' + df['Time (GMT)'])

#df['Date Time (UTC)'] = df['Date Time (UTC)'].tz_localize('utc') 

df.set_index('Date Time (UTC)', inplace=True)
df.index = df.index.to_datetime().tz_localize('utc')

df['WL'] = df['Preliminary (m)'].where(df['Verified (m)'].isnull(), df['Preliminary (m)'])
df['WL'] = df['WL'].replace({'-': np.nan})
df.drop(['Date', 'Time (GMT)', 'Predicted (m)', 'Preliminary (m)', 'Verified (m)'], axis=1, inplace=True)



Station3 = df[df['Station ID'].str.match('9052030')] #Oswego, NY
#Station3['Temp Station ID'] = '13771'
Station3['WL'] = Station3['WL'].astype(float) - 74.2
Station3.rename(columns={'WL':'9052030'}, inplace=True)
del Station3['Station ID']
noaaDFs["9052030"]=9052030

hydrometDF = readHydromet()
pcwlDF = readPCWL()
noaaDF = readNOAA()

# Create 3 minute time series to merge station data to so data gaps can be identified
idx = pd.date_range('06-21-2019 20:00:00', periods=25000, freq='3 min')
ts = pd.Series(range(len(idx)), index=idx)
cts = ts.to_frame()
cts.index = cts.index.to_datetime().tz_localize('utc')
cts.drop(0, axis=1, inplace=True)

final13771 = pd.merge(hydrometDF["Station11985"], pcwlDF["station13988"], how='outer', left_index=True,right_index=True)
final13771 = pd.merge(final13771, pcwlDF["station13590"], how='outer', left_index=True,right_index=True)
final13771 = pd.merge(final13771, pcwlDF["station14400"], how='outer', left_index=True,right_index=True)
final13771 = pd.merge(final13771, noaaDF["9052030"], how='outer', left_index=True,right_index=True)
final13771 = pd.merge(final13771, cts, how='outer', left_index=True,right_index=True)
final13771.to_excel("13771.xlsx")