ฉันมีสองแข่งกัน kart datasets กับ 9 คอลัมน์:
df1:
ฉันกำลังพยายามตั้งหลายเงื่อนไขที่สอง datasets คือเปรียบเทียบแล้วพยายามจะพิมพ์ออกไปจริงหรือไม่จริงถ้าสภาพน่าสนใจหลังจากเปรียบเทียบ. สภาพ:
- race_start(df1)<=race_start(df2)
- race_end(df1)>=race_end(df2)
- safety_start(df1)<=safety_start(df2)
- safety_end(df1)>=safety_end(df2)
- starting_front(df1)<=starting_front(df2)
- starting_back(df1)<=starting_back(df2)
- pitstop(df1)>=pitstop(df2)
- no_pitstop(df1)>=no_pitstop(df2)
- สถานะของ(df1)=สถานะ(df2).
ก่อนฉันพยายามนี้:
import numpy as np
df1['race_start_final'] = np.where(df1.race_start <= df2.race_start, 'True', 'False')
df1['race_end_final'] = np.where(df1.race_end >= df2.race_end, 'True', 'False')
df1['safety_start_final'] = np.where(df1.safety_start <= df2.safety_start, 'True', 'False')
df1['safety_end_final'] = np.where(df1.safety_end >= df2.safety_end, 'True', 'False')
df1['starting_front_final'] = np.where(df1.starting_front <= df2.starting_front, 'True', 'False')
df1['starting_back_final'] = np.where(df1.starting_back <= df2.starting_back, 'True', 'False')
df1['pitstop_final'] = np.where(df1.pitstop >= df2.pitstop, 'True', 'False')
df1['pitstop_final'] = np.where(df1.pitstop >= df2.pitstop, 'True', 'False')
df1['status_final'] = np.where(df1.status == df2.status, 'True', 'False')
แต่ฉันมีข้อผิดพลาดเกิดขึ้นระหว่างพูดว่า:
ValueError: Can only compare identically-labeled Series objects
ฉันทำมันใช่ไหม? ฉันพยายามหาทางเลือกอื่นอทางแก้ปัญหานั่นแต่ไม่เจออะไรที่เกี่ยวข้องกับสิ่งที่ฉันกำลังพยายามทำอย่างไร? ใครบอกฉันว่าขั้นตอนที่ฉันเลือกคือทางที่ถูกต้อ? ขอบคุณ