我已经实现了以下代码(Pandas)来绘制每个不同类别的地图 - 有没有办法提高此代码的性能?处理100K记录需要花费大量时间。
vehicleList = a2.vehicleId.unique()
timeList = a2.time.unique()
dayList = a2.day.unique()
seasonList = a2.season.unique()
for vehicle in vehicleList:
for day in dayList:
for time in timeList:
for season in seasonList:
tempDf = a2[(a2["vehicleId"] == vehicle) & (a2["day"] == day) & (a2["time"] == time) & (a2["season"] == season)]
if not tempDf.empty:
# # Plot Chart
答案 0 :(得分:0)
如果没有您的具体数据,很难了解时间,但您的代码相当于此代码,至少看起来更简单:
a2.groupby([vehicleList, timeLis, dayList, seasonList]).apply(lambda g: g.plot())