0

Im trying to read in a csv file of forex data into my code but I get this error. The csv file clearly has a date column so I am confused

here is my code

data = pd.read_csv('GBPJPY.csv')

data.columns = ['date','open','high','low','close','volume']

data = data.drop_duplicates(keep=False)

data.Date = pd.to_datetime(data.Date)

data = data.set_index(data.Date)

data = ['open','high','low','close','volume']

price = data.close.iloc[:100]

here is some of the csv file

Date,Open,High,Low,Close,Volume
08.03.2018 00:00:00.000 GMT-0500,147.464,147.466,147.405,147.418,169.75
08.03.2018 00:01:00.000 GMT-0500,147.418,147.430,147.404,147.412,234.21
08.03.2018 00:02:00.000 GMT-0500,147.412,147.419,147.398,147.411,179.43
08.03.2018 00:03:00.000 GMT-0500,147.411,147.424,147.403,147.410,149.62
08.03.2018 00:04:00.000 GMT-0500,147.410,147.433,147.407,147.411,188.22
08.03.2018 00:05:00.000 GMT-0500,147.412,147.412,147.392,147.407,209.49
08.03.2018 00:06:00.000 GMT-0500,147.407,147.413,147.397,147.410,216.6
08.03.2018 00:07:00.000 GMT-0500,147.410,147.425,147.404,147.425,236.67
08.03.2018 00:08:00.000 GMT-0500,147.425,147.433,147.423,147.427,204.06
08.03.2018 00:09:00.000 GMT-0500,147.427,147.432,147.400,147.421,184.34
08.03.2018 00:10:00.000 GMT-0500,147.421,147.422,147.411,147.413,164.26
08.03.2018 00:11:00.000 GMT-0500,147.413,147.414,147.397,147.413,107.21
08.03.2018 00:12:00.000 GMT-0500,147.413,147.442,147.412,147.440,159.66
08.03.2018 00:13:00.000 GMT-0500,147.441,147.445,147.423,147.425,154.93
08.03.2018 00:14:00.000 GMT-0500,147.424,147.433,147.424,147.433,120.57
08.03.2018 00:15:00.000 GMT-0500,147.434,147.448,147.434,147.435,188.68
08.03.2018 00:16:00.000 GMT-0500,147.434,147.454,147.434,147.453,229.66

1 Answer 1

1

I guess you renamed columns here in second line

data.columns = ['date','open','high','low','close','volume']

use new name date instead of Date like

...
data.date = pd.to_datetime(data.date)
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.