Setting keep=False should remove all duplicates but if I run my function is still returns a duplicate of the previous row
def date_to_csv():
import pandas as pd
from random import randint
df = pd.read_csv("test.csv")
df = df.append({'Date': datetime.date.today(), 'Price': randint(1,100)}, ignore_index=True)
result_df = df.drop_duplicates(keep=False)
result_df.to_csv('test.csv', mode='a', index=False, header=None)
If my csv file is empty with only the column headers 'Date' and 'Price' and I run my function 3 times it returns this in csv:
Date,Price
2021-06-26,74
2021-06-26,74
2021-06-26,51
2021-06-26,51
2021-06-26,13
When I expect it to return something like this:
Date,Price
2021-06-26,74
2021-06-26,51
2021-06-26,13