Page 1 of 1

xget pandas series/dataframe

Posted: Mon Feb 07, 2022 7:07 am
by amrsherif
Hello,

i would like to know if there is any documentation about importing data from python. I am using the code below. My issue is that when I use xget, the data is imported but the dates are not algined with the dates in my EViews workfile. Is there any way to import the data back where EViews can parse the dates/data and do the alignment?

xopen(p)

xrun "import pandas as pd"
xrun "import pyodbc"

xrun "conn = pyodbc.connect(connection string)"
sql_query="insert sql query here"
xrun df=df1 = pd.read_sql(sql_query,conn)
xrun df.set_index("series_value_date", inplace=True)

xget(name=series1,ptype=dataframe) df

Re: xget pandas series/dataframe

Posted: Mon Feb 07, 2022 8:31 am
by EViews Gareth
All imports done via XGET are just a straight row-by-row insertion. There is no date matching done. Your best bet is to do the xget on a separate page, and then try to line up the dates with a copy.

Re: xget pandas series/dataframe

Posted: Mon Feb 07, 2022 9:08 am
by amrsherif
ok thanks for the info. If i have 2 series, series_values and series_dates (dates can be an alpha series or a regular series), do you know of a simple way to make an eviews series out of them?

i was thinking along the lines of:

series new_series
for !i=1 to @ilast(series_dates)
new_series(!i)=series_values(!i)
next

But i am not sure how to set the dates. Maybe i can use the date series to set the range of the workfile?

Re: xget pandas series/dataframe

Posted: Mon Feb 07, 2022 9:33 am
by amrsherif
this worked: pagestruct @date(series_date)

Thanks for the guidance