In [ ]:
import numpy as np
import pandas as pd
from pandasql import sqldf
In [2]:
path = 'F:\\GHEOR_Rapastinel_Tung_201704_001\\_DATA\\'
In [3]:
df01 = pd.read_sas(path + 'p1p02_cohort_1a.sas7bdat')
df01.head()
Out[3]:
In [35]:
enr = list(df01['ENROLID'])
type(enr)
enr[:6]
enr[1] == 19001
pdx = list(df01['PDX'])
pdx[:6]
pdx[3] == b'29633'
Out[35]:
In [43]:
df01.head()
Out[43]:
In [47]:
q = """
select ENROLID, DAYS
from df01
where days = 1 ;
"""
df02 = sqldf(q)
df02.head()
Out[47]:
In [9]:
path = "C:\\Users\\Wang_Degang\\Documents\\Python Scripts\\"
In [7]:
df01 = pd.read_sas(path + 'ccaed11test.sas7bdat')
df01.tail()
Out[7]:
In [3]:
# ccaed111 = pd.read_sas("G:\ccaed111.sas7bdat")
In [ ]:
In [18]:
from sas7bdat import SAS7BDAT
rows = 0
with SAS7BDAT(path + "ccaed11test.sas7bdat") as f:
ccaed111 = f.to_data_frame()
rows += len(ccaed111)
print("read in{: ,} rows".format(rows))
In [19]:
ccaed111.head()
Out[19]:
In [13]:
df = SAS7BDAT(path + "ccaed11test.sas7bdat").to_data_frame()
In [15]:
len(df)
Out[15]:
In [20]:
df.tail()
Out[20]:
In [ ]:
df = SAS7BDAT("G:\ccaed111.sas7bdat").to_data_frame()
In [5]:
import pandas as pd
from io import StringIO
csv = r"""dummy,date,loc,x
bar,20090101,a,1
bar,20090102,a,3
bar,20090103,a,5
bar,20090101,b,1
bar,20090102,b,3
bar,20090103,b,5"""
df = pd.read_csv(StringIO(csv),
header=0,
index_col=["date", "loc"],
usecols=["date", "loc", "x"],
parse_dates=["date"])
In [6]:
df
Out[6]:
In [2]:
from time import sleep, perf_counter as pc
t0 = pc()
sleep(70)
print(pc()-t0)
In [3]:
from datetime import datetime
startTime= datetime.now()
t0 = pc()
sleep(70)
print(pc()-t0)
timeElapsed=datetime.now()-startTime
print(timeElapsed)
print('Time elpased (hh:mm:ss.ms) {}'.format(timeElapsed))
In [1]:
# python seeks modules under these pathes
import sys
from pprint import pprint as p
p(sys.path)
In [ ]:
import