This Jupyter notebook provides the commands used in the article Great tip for dynamic data selection using SAS Viya and Python.
In [1]:
import pandas as pd
import swat
In [2]:
conn = swat.CAS('sasserver.demo.sas.com',8777,'sasdemo','Orion123')
In [3]:
conn
Out[3]:
In [4]:
df=conn.upload('https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv')
In [5]:
tbl = df.casTable
In [8]:
sorttbl = tbl.sort_values(['sepal_length','sepal_width'],
ascending=[False,True])
In [9]:
expr = sorttbl.petal_length > 6.5
In [10]:
newtbl = sorttbl[expr]
In [11]:
newtbl.head()
Out[11]:
In [12]:
newtbl = sorttbl[sorttbl.petal_length > 6.5]
In [13]:
newtbl.head()
Out[13]:
In [14]:
newtbl2 = newtbl[newtbl.petal_width < 2.2]
In [15]:
newtbl2.head()
Out[15]:
In [16]:
sorttbl[(sorttbl.petal_length > 6.5) &
(sorttbl.petal_width < 2.2)].head()
Out[16]:
In [17]:
sorttbl[(sorttbl.petal_length > 6.5) &
(sorttbl.petal_width < 2.2)]
Out[17]:
In [18]:
sorttbl[(sorttbl.petal_length + sorttbl.petal_width)
* 2 > 17.5].head()
Out[18]:
In [19]:
sorttbl[sorttbl.species.str.upper().str.startswith('SET')
].head()
Out[19]: