Python 在两个不同的列上合并或合并三个数据帧

Python 在两个不同的列上合并或合并三个数据帧,python,pandas,dataframe,merge,concatenation,Python,Pandas,Dataframe,Merge,Concatenation,我有三个数据帧 d.head() hotel DATE 0 Resort Hotel 2015-07-01 1 Resort Hotel 2015-07-01 2 Resort Hotel 2015-07-01 3 Resort Hotel 2015-07-01 4 Resort Hotel 2015-07-01 数据帧d约有100000行,其他两个数据帧约有500行。我正在尝试根据列hotel和DATE将P

我有三个数据帧

d.head()

        hotel          DATE
0   Resort Hotel    2015-07-01
1   Resort Hotel    2015-07-01
2   Resort Hotel    2015-07-01
3   Resort Hotel    2015-07-01
4   Resort Hotel    2015-07-01
数据帧
d
约有100000行,其他两个数据帧约有500行。我正在尝试根据列
hotel
DATE
PRCP
TAVG
列添加到数据框
d
。我试过了

d.merge(r_w, how='outer', on=['hotel', 'DATE'])
但我得到了一个错误:

ValueError: You are trying to merge on datetime64[ns] and object columns. If you wish to proceed you should use pd.concat
为了解决此问题,我尝试执行
r_w.loc['DATE']=pd.To_datetime(r_w.DATE)
,但仍然出现相同的错误,并出现以下警告:

SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  iloc._setitem_with_indexer(indexer, value, self.name)

如何合并/合并列以及警告的含义是什么?

使用
r\u w['DATE']=pd.to\u datetime(r\u.DATE)
而不使用
.loc
?@SeaBean我得到另一个警告和4个附加列:
PRCP\u x
PRCP\u y
TAVG\u x
tavu y
。我不想再增加4列。
SettingWithCopyWarning:试图在数据帧切片的副本上设置值。尝试使用.loc[行索引器、列索引器]=值,请参见文档中的注意事项:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-vs-a-copy
你的意思是通过修改上面的代码而没有.loc?@SeaBean是的,但是警告似乎要求我使用
.loc
ValueError: You are trying to merge on datetime64[ns] and object columns. If you wish to proceed you should use pd.concat
SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  iloc._setitem_with_indexer(indexer, value, self.name)