@@ -141,9 +141,11 @@ def test_rd_drinking():
141
141
142
142
@pytest .mark .integration
143
143
def test_its ():
144
- df = cp .load_data ("its" )
145
- df ["date" ] = pd .to_datetime (df ["date" ])
146
- df .set_index ("date" , inplace = True )
144
+ df = (
145
+ cp .load_data ("its" )
146
+ .assign (date = lambda x : pd .to_datetime (x ["date" ]))
147
+ .set_index ("date" )
148
+ )
147
149
treatment_time = pd .to_datetime ("2017-01-01" )
148
150
result = cp .pymc_experiments .SyntheticControl (
149
151
df ,
@@ -159,8 +161,11 @@ def test_its():
159
161
160
162
@pytest .mark .integration
161
163
def test_its_covid ():
162
- df = cp .load_data ("covid" )
163
- df ["date" ] = pd .to_datetime (df ["date" ])
164
+ df = (
165
+ cp .load_data ("covid" )
166
+ .assign (date = lambda x : pd .to_datetime (x ["date" ]))
167
+ .set_index ("date" )
168
+ )
164
169
df = df .set_index ("date" )
165
170
treatment_time = pd .to_datetime ("2020-01-01" )
166
171
result = cp .pymc_experiments .SyntheticControl (
@@ -193,12 +198,14 @@ def test_sc():
193
198
194
199
@pytest .mark .integration
195
200
def test_sc_brexit ():
196
- df = cp .load_data ("brexit" )
197
- df ["Time" ] = pd .to_datetime (df ["Time" ])
198
- df .set_index ("Time" , inplace = True )
199
- df = df .iloc [df .index > "2009" , :]
201
+ df = (
202
+ cp .load_data ("brexit" )
203
+ .assign (Time = lambda x : pd .to_datetime (x ["Time" ]))
204
+ .set_index ("Time" )
205
+ .loc [lambda x : x .index >= "2009-01-01" ]
206
+ .drop (["Japan" , "Italy" , "US" , "Spain" ], axis = 1 )
207
+ )
200
208
treatment_time = pd .to_datetime ("2016 June 24" )
201
- df = df .drop (["Japan" , "Italy" , "US" , "Spain" ], axis = 1 )
202
209
target_country = "UK"
203
210
all_countries = df .columns
204
211
other_countries = all_countries .difference ({target_country })
@@ -235,9 +242,11 @@ def test_ancova():
235
242
236
243
@pytest .mark .integration
237
244
def test_geolift1 ():
238
- df = cp .load_data ("geolift1" )
239
- df ["time" ] = pd .to_datetime (df ["time" ])
240
- df .set_index ("time" , inplace = True )
245
+ df = (
246
+ cp .load_data ("geolift1" )
247
+ .assign (time = lambda x : pd .to_datetime (x ["time" ]))
248
+ .set_index ("time" )
249
+ )
241
250
treatment_time = pd .to_datetime ("2022-01-01" )
242
251
result = cp .pymc_experiments .SyntheticControl (
243
252
df ,
0 commit comments