Posts: 5
Threads: 2
Joined: Nov 2020
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.signal import argrelextrema
data = pd.read_csv("Data/EURUSD60.csv", delimiter="\t")
print(data)
data = pd.DataFrame(data=data, columns=["Date", "Open", "High", "Low", "Close", "Volume"])
print(data) and output is:
I'm trying some strategies and calculations on prices. Previously I was working on windows (I was using excel for the python file) then I installed manjaro and encountered such problem with the csv file.
Posts: 12,019
Threads: 483
Joined: Sep 2016
NaN is missing data or None (can be used interchangeably).
Posts: 5
Threads: 2
Joined: Nov 2020
(Jan-23-2021, 10:53 PM)Larz60+ Wrote: NaN is missing data or None (can be used interchangeably).
Yes I know, but why ? :)As you can see in the picture, when there is data after the first "read_csv", NaN returns after naming the columns.
Posts: 12,019
Threads: 483
Joined: Sep 2016
Jan-24-2021, 06:35 PM
(This post was last modified: Jan-24-2021, 06:36 PM by Larz60+.)
First change line 10 to:
df = pd.DataFrame(data=data, columns=["Date", "Open", "High", "Low", "Close", "Volume"])
you were overwriting 'data'.
Then, to isolate the data, please change line 8 to:
print(f"\nCSV data:\n{data}")
and line 12 to:
print(f"\ndataframe:\n{df}")
Show results again
Posts: 5
Threads: 2
Joined: Nov 2020
Jan-26-2021, 06:22 PM
(This post was last modified: Jan-26-2021, 06:22 PM by epsilon.)
(Jan-24-2021, 06:35 PM)Larz60+ Wrote: First change line 10 to:
df = pd.DataFrame(data=data, columns=["Date", "Open", "High", "Low", "Close", "Volume"])
you were overwriting 'data'.
Then, to isolate the data, please change line 8 to:
print(f"\nCSV data:\n{data}")
and line 12 to:
print(f"\ndataframe:\n{df}")
Show results again
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.signal import argrelextrema
data = pd.read_csv("Data/EURUSD60.csv", delimiter="\t")
print(f"\nCSV data:\n{data}")
df = pd.DataFrame(data=data, columns=["Date", "Open", "High", "Low", "Close", "Volume"])
print(f"\ndataframe:\n{df}") I did, but the result is the same as in the picture
Posts: 12,019
Threads: 483
Joined: Sep 2016
The new output should contain the two print statements, which will isolate the output to the different sections of software. That was what I was interested in seeing.
If you don't see the print statements, something else is happening here.
Posts: 8,148
Threads: 159
Joined: Sep 2016
Jan-26-2021, 07:19 PM
(This post was last modified: Jan-26-2021, 07:19 PM by buran.)
Looking at the screenshot, note that initial data dataframe does not have these columns. Confirmed by 99 rows x6 columns (index is 0 to 98)
index 0 is 2012-12-14 18:00, and the column names are values for 2012-12-24 17:00
I guess your csv file has no header and you need to specify columns when reading it.
Can you show your file (e.g. top 10 rows of it?)
or try
data = pd.read_csv("Data/EURUSD60.csv", delimiter="\t", names=["Date", "Open", "High", "Low", "Close", "Volume"])
Posts: 5
Threads: 2
Joined: Nov 2020
(Jan-26-2021, 07:19 PM)buran Wrote: Looking at the screenshot, note that initial data dataframe does not have these columns. Confirmed by 99 rows x6 columns (index is 0 to 98)
index 0 is 2012-12-14 18:00, and the column names are values for 2012-12-24 17:00
I guess your csv file has no header and you need to specify columns when reading it.
Can you show your file (e.g. top 10 rows of it?)
or try
data = pd.read_csv("Data/EURUSD60.csv", delimiter="\t", names=["Date", "Open", "High", "Low", "Close", "Volume"])
Yes, there is no title in the csv-file, as you said, I added a header(name=[..]) in "read_csv" and it's okay.
Thanks!
|