df = pd.read_csv("foo.csv")
# drop NaN
df = df.dropna()
df.iloc[0,0] = 1
# drop time
for i in range(3):
df.iloc[0,0] = 2
df.iloc[:,i] = datetime.strptime(df.iloc[:,i], "%Y-%m-%dT%H:%M:%S%z")
I get this error:
File "accuracy.py", line 19
df.iloc[0,0] = 2
^
> SyntaxError: invalid character in identifier
I want to modify every value in the dataframe, so that I can work with the dates in there. However, when I use df.iloc
in the for-loop, I get a similar Sytax Error to this one. I tried it again with simpler code, hence the df.iloc[0,0] = 2
, but it gives the same error I would get from the other one. I also tried the code outside of the loop, and that doesn't result in an error, so I'm confused.
I'm working from my terminal since I can't download the csv I'm working on, which makes debugging a little more interesting. Mostly because I cannot print things if the file does not compile.
Any idea what the problem could be?