I have a cvs file with data that I only want to update once and if by mistake the update runs again I need to ensure the data does not update again. Before the update runs the data has no decimal places, but after the update each value is divided by 100 so each line will have 2 decimal place. My thought here is to count the number of characters after the decimal place.
This is what I want to achieve:
If >= 2 then do not update
Else if <=2 then update
I have tried to count the characters once an update has run, but some value will have 2 zero's - 120.00. When I count that I only get 1 and not 2. I need to get a 2. Essentially each updated value will have 2 decimal places even if both are zero's.
df = pd.read_csv(input.csv, names=['Open','High','Low','Close'])
df = df['Close'].astype(str).str.extract('\.(.*)').str.len()
print(df)