diffindiff 2.0.0__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,24 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: diffindiff
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
7
7
  Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy
9
+ Requires-Dist: pandas
10
+ Requires-Dist: statsmodels
11
+ Requires-Dist: matplotlib
12
+ Requires-Dist: datetime
13
+ Requires-Dist: scikit-learn
14
+ Requires-Dist: xgboost
15
+ Requires-Dist: lightgbm
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: requires-dist
21
+ Dynamic: summary
8
22
 
9
23
  # diffindiff: Difference-in-Differences (DiD) Analysis Python Library
10
24
 
@@ -1,9 +1,9 @@
1
1
  #-------------------------------------------------------------------------------
2
2
  # Name: didanalysis (diffindiff)
3
3
  # Purpose: Analysis functions for difference-in-differences analyses
4
- # Author: Thomas Wieland (geowieland@googlemail.com)
5
- # Version: 2.0.0
6
- # Last update: 2025-04-15 07:11
4
+ # Author: Thomas Wieland (mail: geowieland@googlemail.com, ORCID: 0000-0001-5168-9846)
5
+ # Version: 2.0.1
6
+ # Last update: 2025-04-15 18:43
7
7
  # Copyright (c) 2025 Thomas Wieland
8
8
  #-------------------------------------------------------------------------------
9
9
 
@@ -13,7 +13,7 @@ from statsmodels.formula.api import ols
13
13
  import numpy as np
14
14
  import matplotlib.pyplot as plt
15
15
  from matplotlib.dates import DateFormatter
16
- import didtools
16
+ import diffindiff.didtools
17
17
 
18
18
 
19
19
  class DiffModel:
@@ -686,7 +686,7 @@ class DiffModel:
686
686
  model_data = self.data[2]
687
687
  model_config = self.data[1]
688
688
 
689
- modeldata_isparallel = didtools.is_parallel(
689
+ modeldata_isparallel = diffindiff.didtools.is_parallel(
690
690
  data = model_data,
691
691
  unit_col = model_config["unit_col"],
692
692
  time_col = model_config["time_col"],
@@ -1275,7 +1275,7 @@ def did_analysis(
1275
1275
  missing_replace_by_zero: bool = False
1276
1276
  ):
1277
1277
 
1278
- didtools.check_columns(
1278
+ diffindiff.didtools.check_columns(
1279
1279
  df = data,
1280
1280
  columns = [unit_col, time_col, outcome_col]
1281
1281
  )
@@ -1287,7 +1287,7 @@ def did_analysis(
1287
1287
  no_treatments = len(treatment_col)
1288
1288
  if no_treatments == 0:
1289
1289
  raise ValueError ("No treatment(s) in treatment_col stated.")
1290
- didtools.check_columns(
1290
+ diffindiff.didtools.check_columns(
1291
1291
  df = data,
1292
1292
  columns = treatment_col
1293
1293
  )
@@ -1301,12 +1301,12 @@ def did_analysis(
1301
1301
  treatment_diagnostics = {}
1302
1302
  staggered_adoption = False
1303
1303
  for i, treatment in enumerate(treatment_col):
1304
- is_notreatment = didtools.is_notreatment(
1304
+ is_notreatment = diffindiff.didtools.is_notreatment(
1305
1305
  data = data,
1306
1306
  unit_col = unit_col,
1307
1307
  treatment_col = treatment
1308
1308
  )
1309
- is_parallel = didtools.is_parallel(
1309
+ is_parallel = diffindiff.didtools.is_parallel(
1310
1310
  data = data,
1311
1311
  unit_col = unit_col,
1312
1312
  time_col = time_col,
@@ -1315,13 +1315,13 @@ def did_analysis(
1315
1315
  pre_post = pre_post,
1316
1316
  alpha = confint_alpha
1317
1317
  )
1318
- is_simultaneous = didtools.is_simultaneous(
1318
+ is_simultaneous = diffindiff.didtools.is_simultaneous(
1319
1319
  data = data,
1320
1320
  unit_col = unit_col,
1321
1321
  time_col = time_col,
1322
1322
  treatment_col = treatment
1323
1323
  )
1324
- is_binary = didtools.is_binary(
1324
+ is_binary = diffindiff.didtools.is_binary(
1325
1325
  data = data,
1326
1326
  treatment_col = treatment
1327
1327
  )
@@ -1363,7 +1363,7 @@ def did_analysis(
1363
1363
  if isinstance (after_treatment_col, str):
1364
1364
  after_treatment_col = [after_treatment_col]
1365
1365
  after_treatment_col = [entry for entry in after_treatment_col if entry is not None]
1366
- didtools.check_columns(
1366
+ diffindiff.didtools.check_columns(
1367
1367
  df = data,
1368
1368
  columns = after_treatment_col
1369
1369
  )
@@ -1373,7 +1373,7 @@ def did_analysis(
1373
1373
  if isinstance (TG_col, str):
1374
1374
  TG_col = [TG_col]
1375
1375
  TG_col = [entry for entry in TG_col if entry is not None]
1376
- didtools.check_columns(
1376
+ diffindiff.didtools.check_columns(
1377
1377
  df = data,
1378
1378
  columns = TG_col
1379
1379
  )
@@ -1385,7 +1385,7 @@ def did_analysis(
1385
1385
  if isinstance (TT_col, str):
1386
1386
  TT_col = [TT_col]
1387
1387
  TT_col = [entry for entry in TT_col if entry is not None]
1388
- didtools.check_columns(
1388
+ diffindiff.didtools.check_columns(
1389
1389
  df = data,
1390
1390
  columns = TT_col
1391
1391
  )
@@ -1394,14 +1394,14 @@ def did_analysis(
1394
1394
  FE_time = True
1395
1395
 
1396
1396
  if covariates is not None or (isinstance (covariates, list) and len(covariates) > 0):
1397
- didtools.check_columns(
1397
+ diffindiff.didtools.check_columns(
1398
1398
  df = data,
1399
1399
  columns = covariates
1400
1400
  )
1401
1401
  cols_relevant = cols_relevant + covariates
1402
1402
 
1403
1403
  if group_by is not None and group_by != "":
1404
- didtools.check_columns(
1404
+ diffindiff.didtools.check_columns(
1405
1405
  df = data,
1406
1406
  columns = [group_by]
1407
1407
  )
@@ -1412,13 +1412,13 @@ def did_analysis(
1412
1412
  data = data[cols_relevant].copy()
1413
1413
 
1414
1414
  if "date_counter" not in data.columns:
1415
- data = didtools.date_counter(
1415
+ data = diffindiff.didtools.date_counter(
1416
1416
  data,
1417
1417
  time_col,
1418
1418
  new_col = "date_counter"
1419
1419
  )
1420
1420
 
1421
- modeldata_ismissing = didtools.is_missing(
1421
+ modeldata_ismissing = diffindiff.didtools.is_missing(
1422
1422
  data,
1423
1423
  drop_missing = drop_missing,
1424
1424
  missing_replace_by_zero = missing_replace_by_zero
@@ -1435,7 +1435,7 @@ def did_analysis(
1435
1435
  print ("Missing values are not cleaned. Model may crash.")
1436
1436
 
1437
1437
  other_cols_relevant = [col for col in cols_relevant if col not in [unit_col, time_col, outcome_col]]
1438
- modeldata_isbalanced = didtools.is_balanced(
1438
+ modeldata_isbalanced = diffindiff.didtools.is_balanced(
1439
1439
  data = data,
1440
1440
  unit_col = unit_col,
1441
1441
  time_col = time_col,
@@ -1474,7 +1474,7 @@ def did_analysis(
1474
1474
  did_formula = did_formula + f'+ {" + ".join(after_treatment_col)}'
1475
1475
 
1476
1476
  if FE_unit:
1477
- unit_col_todummies = didtools.to_dummies(
1477
+ unit_col_todummies = diffindiff.didtools.to_dummies(
1478
1478
  data = data,
1479
1479
  col = unit_col,
1480
1480
  prefix = "UNIT",
@@ -1486,7 +1486,7 @@ def did_analysis(
1486
1486
  dummy_unit_original = list(unit_col_todummies[2][unit_col].values)
1487
1487
 
1488
1488
  if FE_time:
1489
- time_col_todummies = didtools.to_dummies(
1489
+ time_col_todummies = diffindiff.didtools.to_dummies(
1490
1490
  data = data,
1491
1491
  col = time_col,
1492
1492
  prefix = "TIME",
@@ -1501,7 +1501,7 @@ def did_analysis(
1501
1501
  if group_by is None or group_by == "":
1502
1502
  print ("WARNING: Grouping variable is not defined. No group-specific analyses are carried out. Define a grouping variable using group_by.")
1503
1503
  else:
1504
- group_col_todummies = didtools.to_dummies(
1504
+ group_col_todummies = diffindiff.didtools.to_dummies(
1505
1505
  data = data,
1506
1506
  col = group_by,
1507
1507
  prefix = "GROUP",
@@ -1515,7 +1515,7 @@ def did_analysis(
1515
1515
  if GTT:
1516
1516
  if group_by is not None and group_by != "":
1517
1517
  if "date_counter" not in data.columns:
1518
- data = didtools.date_counter(
1518
+ data = diffindiff.didtools.date_counter(
1519
1519
  data,
1520
1520
  time_col,
1521
1521
  new_col="date_counter"
@@ -1531,7 +1531,7 @@ def did_analysis(
1531
1531
 
1532
1532
  if ITT:
1533
1533
  if "date_counter" not in data.columns:
1534
- data = didtools.date_counter(
1534
+ data = diffindiff.didtools.date_counter(
1535
1535
  data,
1536
1536
  time_col,
1537
1537
  new_col="date_counter"
@@ -1577,7 +1577,7 @@ def did_analysis(
1577
1577
  did_formula = did_formula + f'+{covariates_join}'
1578
1578
 
1579
1579
  if len(group_benefit) > 0:
1580
- group_benefit = didtools.unique(group_benefit)
1580
+ group_benefit = diffindiff.didtools.unique(group_benefit)
1581
1581
  if no_treatments == 1:
1582
1582
  DDD = True
1583
1583
  if "TG_"+treatment_diagnostics[0]["treatment"] not in data.columns:
@@ -1,9 +1,9 @@
1
1
  #-------------------------------------------------------------------------------
2
2
  # Name: diddata (diffindiff)
3
3
  # Purpose: Creating data for Difference-in-Differences Analysis
4
- # Author: Thomas Wieland (geowieland@googlemail.com)
5
- # Version: 2.0.0
6
- # Last update: 2025-04-15 07:21
4
+ # Author: Thomas Wieland (mail: geowieland@googlemail.com, ORCID: 0000-0001-5168-9846)
5
+ # Version: 2.0.1
6
+ # Last update: 2025-04-15 18:43
7
7
  # Copyright (c) 2025 Thomas Wieland
8
8
  #-------------------------------------------------------------------------------
9
9
 
@@ -11,8 +11,8 @@ import pandas as pd
11
11
  import numpy as np
12
12
  from datetime import datetime, timedelta
13
13
  import re
14
- import didanalysis
15
- import didtools
14
+ import diffindiff.didanalysis
15
+ import diffindiff.didtools
16
16
 
17
17
 
18
18
  class DiffGroups:
@@ -80,8 +80,8 @@ def create_groups(
80
80
  if treatment_name is not None:
81
81
  TG_col = "TG_"+treatment_name
82
82
 
83
- treatment_group_unique = didtools.unique(treatment_group)
84
- control_group_unique = didtools.unique(control_group)
83
+ treatment_group_unique = diffindiff.didtools.unique(treatment_group)
84
+ control_group_unique = diffindiff.didtools.unique(control_group)
85
85
 
86
86
  treatment_group_N = len(treatment_group_unique)
87
87
  control_group_N = len(control_group_unique)
@@ -578,7 +578,7 @@ class DiffData:
578
578
  if time_col is None or counterfactual_outcome_col is None:
579
579
  raise ValueError("time_col and counterfactual_outcome_col must be stated")
580
580
 
581
- didtools.check_columns(
581
+ diffindiff.didtools.check_columns(
582
582
  df = additional_df,
583
583
  columns = [counterfactual_outcome_col, time_col]
584
584
  )
@@ -730,7 +730,7 @@ class DiffData:
730
730
  if groups_config[0]["DDD"]:
731
731
  group_benefit = did_modeldata.loc[did_modeldata["group_benefit"] == 1, "unit_UID"].unique()
732
732
 
733
- did_results = didanalysis.did_analysis(
733
+ did_results = diffindiff.didanalysis.did_analysis(
734
734
  data = did_modeldata,
735
735
  TG_col = TG_col,
736
736
  TT_col = TT_col,
@@ -810,7 +810,7 @@ def merge_data(
810
810
  )
811
811
 
812
812
  if drop_missing or missing_replace_by_zero:
813
- modeldata_ismissing = didtools.is_missing(
813
+ modeldata_ismissing = diffindiff.didtools.is_missing(
814
814
  data = did_modeldata,
815
815
  drop_missing = drop_missing,
816
816
  missing_replace_by_zero = missing_replace_by_zero
@@ -943,7 +943,7 @@ def create_counterfactual(
943
943
  data = data[data[unit_col].astype(str) != cf_for_unit]
944
944
  data_unit = data[data[unit_col].astype(str) == cf_for_unit]
945
945
 
946
- isnotreatment = didtools.is_notreatment(
946
+ isnotreatment = diffindiff.didtools.is_notreatment(
947
947
  data = data,
948
948
  unit_col = unit_col,
949
949
  treatment_col = treatment_col
@@ -956,7 +956,7 @@ def create_counterfactual(
956
956
  time_col = time_col,
957
957
  treatment_col = treatment_col
958
958
  )
959
- units = didtools.unique(units_tt[unit_col])
959
+ units = diffindiff.didtools.unique(units_tt[unit_col])
960
960
 
961
961
  if not isnotreatment[0]:
962
962
  print ("No no-treatment control group. Counterfactual will not cover full treatment time.")
@@ -981,7 +981,7 @@ def create_counterfactual(
981
981
  ignore_index=True
982
982
  )
983
983
 
984
- counterfactual_pred = didtools.model_wrapper(
984
+ counterfactual_pred = diffindiff.didtools.model_wrapper(
985
985
  y = data_cf[y],
986
986
  X = data_cf[X],
987
987
  model_type = model_type,
@@ -1,9 +1,9 @@
1
1
  # -------------------------------------------------------------------------------
2
2
  # Name: didtools (diffindiff)
3
3
  # Purpose: Creating data for Difference-in-Differences Analysis
4
- # Author: Thomas Wieland (geowieland@googlemail.com)
5
- # Version: 2.0.0
6
- # Last update: 2025-04-15 07:05
4
+ # Author: Thomas Wieland (mail: geowieland@googlemail.com, ORCID: 0000-0001-5168-9846)
5
+ # Version: 2.0.1
6
+ # Last update: 2025-04-15 18:44
7
7
  # Copyright (c) 2025 Thomas Wieland
8
8
  #-------------------------------------------------------------------------------
9
9
 
@@ -3,8 +3,8 @@
3
3
  # Name: tests_diffindiff
4
4
  # Purpose: Tests and examples for the diffindiff package
5
5
  # Author: Thomas Wieland (mail: geowieland@googlemail.com, ORCID: 0000-0001-5168-9846)
6
- # Version: 2.0.0
7
- # Last update: 2025-04-15 07:12
6
+ # Version: 2.0.1
7
+ # Last update: 2025-04-15 18:43
8
8
  # Copyright (c) 2025 Thomas Wieland
9
9
  #------------------------------------------------------------------------------------------
10
10
 
@@ -1,10 +1,24 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: diffindiff
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
7
7
  Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy
9
+ Requires-Dist: pandas
10
+ Requires-Dist: statsmodels
11
+ Requires-Dist: matplotlib
12
+ Requires-Dist: datetime
13
+ Requires-Dist: scikit-learn
14
+ Requires-Dist: xgboost
15
+ Requires-Dist: lightgbm
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: requires-dist
21
+ Dynamic: summary
8
22
 
9
23
  # diffindiff: Difference-in-Differences (DiD) Analysis Python Library
10
24
 
@@ -7,7 +7,7 @@ def read_README():
7
7
 
8
8
  setup(
9
9
  name='diffindiff',
10
- version='2.0.0',
10
+ version='2.0.1',
11
11
  description='diffindiff: Python library for convenient Difference-in-Differences Analyses',
12
12
  packages=find_packages(include=["diffindiff", "diffindiff.tests"]),
13
13
  include_package_data=True,
File without changes
File without changes
File without changes