我有2个数据框,data
和data_car_types
。
合并后:
data_all = pd.merge(data, data_car_types, on = 'vin', how = 'right')
我得到一个包含此信息的数据框:
Data columns (total 21 columns):
vin 11391 non-null object
time_stamp 5700 non-null object
time_stamp1 5700 non-null object
abs 5700 non-null object
city 5700 non-null object
accelerator_pedal_position 5700 non-null float64
brake_pedal_status 5700 non-null object
engine_temperature 5700 non-null float64
engineoil 5700 non-null float64
fuel 5700 non-null float64
headlamp_status 5700 non-null object
ignition_status 5700 non-null object
odometer 5700 non-null float64
outside_temperature 5700 non-null float64
parking_brake_status 5700 non-null object
speed 5700 non-null float64
tirepressure 5700 non-null float64
transmission_gear_position 5700 non-null object
windshild_wiper_status 5700 non-null object
time_stamp2 5700 non-null object
car_type 11391 non-null obj
等
当我想按car_type
分组时,它失败了:
data_all.groupby('car_type')
我明白了:
pandas.index.IndexEngine.get_loc中的pandas / index.pyx (pandas / index.c:3979)()pandas / index.pyx in pandas.index.IndexEngine.get_loc(pandas / index.c:3843)()
pandas.hashtable.PyObjectHashTable.get_item中的pandas / hashtable.pyx (熊猫/ hashtable.c:12265)()
pandas.hashtable.PyObjectHashTable.get_item中的pandas / hashtable.pyx (熊猫/ hashtable.c:12216)()
KeyError:'car_type'
我不明白出了什么问题?