I'm trying to append new values to a pandas series inside a while loop.
But I'm getting a syntax error on the string formatting...
import pandas as pd
sClose = pd.Series()
close = history['candles'][0]['closeMid']
time = history['candles'][0]['time']
sClose = s.Close.append(pd.Series(%s,index=[%s]))% (close, time)
How do i dynamically put new values inside the appended series during each loop?
You should use quote around
%s
.Something like this would do the trick:
but not sure why you need to transtype to string. If
close
andtime
are numbers (or datetime), you can simply do: