我试图在多个列上加入两个数据格式。即使所有列都存在于两个数据格式中,我在执行pd.merge时也会得到一个关键错误。
当我尝试做一个 "ValueError: len(left_on) must equal the number of levels in the index of "right"" 时,我就得到了.join
"ValueError: len(left_on) must equal the number of levels in the index of "right""
Dataframe 1:
>>data.columns Index(['weather.description', 'weather.icon', 'weather.id', 'weather.main', 'dt', 'main.pressure', 'main.temp_min', 'main.temp_max', 'main.temp', 'main.humidity', 'main.grnd_level', 'main.sea_level', 'wind.speed', 'wind.deg', 'wind.gust', 'id', 'day', 'month', 'hour', 'dd', 'year'], dtype='object') >>data.dtypes weather.description object weather.icon object weather.id int64 weather.main object dt object main.pressure float64 main.temp_min float64 main.temp_max float64 main.temp float64 main.humidity int32 main.grnd_level float64 main.sea_level float64 wind.speed float64 wind.deg float64 wind.gust float64 id float64 day object month object year object hour object dd object dtype: object
Dataframe 2:
>>df_crime.columns Index(['beat', 'disposition', 'event_date', 'event_number', 'general_location', 'location_1', 'map_x', 'map_y', 'type', 'type_description', 'ward', 'day', 'year', 'month', 'dd', 'hour'], dtype='object') >>df_crime.dtypes beat object disposition object event_date object event_number object general_location object location_1 object map_x float64 map_y float64 type object type_description object ward float64 day object year object month object