-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrexp.py
More file actions
38 lines (25 loc) · 847 Bytes
/
rexp.py
File metadata and controls
38 lines (25 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import pandas as pd
import rpy2.robjects as ro
from rpy2.robjects.packages import importr
# tzlocal = importr('tzlocal')
from rpy2.robjects import pandas2ri
from rpy2.robjects.conversion import localconverter
base = importr('base')
utils = importr('utils')
## only need to install once ##
# utils.install_packages('PlayerRatings')
# utils.chooseCRANmirror(ind=65)
pyPR = importr('PlayerRatings')
pd_df = pd.DataFrame({
'Time Period': [1,1,1],
'Player 1': [1,2,3],
'Player 2': [2,3,1],
'Result': [1,0,0]
})
print(pd_df)
with localconverter(ro.default_converter + pandas2ri.converter):
r_from_pd_df = ro.conversion.py2rpy(pd_df)
print(r_from_pd_df)
sobj = pyPR.steph(r_from_pd_df, cval=8, hval=8)
#