I'm using this function and APScheduler to add rows to a Dataframe everyhour. The problem is every time it runs it overwrites the previous entry so its not really "appending" anything.
def SMSx(frame):
SMS(frame)
frame = frame.append(SMS.SMSdf)
frame = frame[frame.a != "test"]
frame = DataFrame(frame, columns=['Time', 'Hour', 'Date', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'Total', 'Bucket'])
frame.to_excel('Sprint_Log.xlsx', 'Sheet 1', index=False)
SMSx.frame = frame
If I use the exact same code (below) and run it manually it works just fine. I'm not too sure what is going on here. SMS.SMSdf is a data frame from the SMS function.
SMS(frame)
frame = frame.append(SMS.SMSdf)
frame = frame[frame.a != "test"]
frame = DataFrame(frame, columns=['Time', 'Hour', 'Date', 'Day', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'Total', 'Bucket'])
frame.to_excel('Sprint_Log.xlsx', 'Sheet 1', index=False)
SMSx.frame = frame
Thank you for the help!
Code that worked:
def SMSx(frame_temp, frame_perm):
SMS(frame_temp)
try:
frame_perm = DataFrame.from_csv('Sprint_Log.csv')
except:
pass
frame_perm = frame_perm.append(SMS.SMSdf)
frame_perm = frame_perm.drop_duplicates()
frame_perm = frame_perm[frame_perm.Ready != "test"]
frame_perm = DataFrame(frame_perm, columns=['Time', 'Hour', 'Date', 'Day', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'Total', 'Bucket'])
frame_perm.to_csv('Sprint_Log.csv')
SMSx.frame2 = frame_perm