xget pandas series/dataframe

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

amrsherif
Posts: 99
Joined: Mon Jul 23, 2018 4:34 pm

xget pandas series/dataframe

Postby amrsherif » Mon Feb 07, 2022 7:07 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13305
Joined: Tue Sep 16, 2008 5:38 pm

Re: xget pandas series/dataframe

Postby EViews Gareth » Mon Feb 07, 2022 8:31 am

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.
Follow us on Twitter @IHSEViews

amrsherif
Posts: 99
Joined: Mon Jul 23, 2018 4:34 pm

Re: xget pandas series/dataframe

Postby amrsherif » Mon Feb 07, 2022 9:08 am

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?

amrsherif
Posts: 99
Joined: Mon Jul 23, 2018 4:34 pm

Re: xget pandas series/dataframe

Postby amrsherif » Mon Feb 07, 2022 9:33 am

this worked: pagestruct @date(series_date)

Thanks for the guidance


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 29 guests