diffindiff 2.4.1__tar.gz → 2.4.2__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.
Files changed (21) hide show
  1. {diffindiff-2.4.1 → diffindiff-2.4.2}/PKG-INFO +5 -5
  2. {diffindiff-2.4.1 → diffindiff-2.4.2}/README.md +4 -4
  3. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/config.py +3 -3
  4. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/didanalysis_helper.py +15 -12
  5. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/diddata.py +60 -24
  6. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff.egg-info/PKG-INFO +5 -5
  7. {diffindiff-2.4.1 → diffindiff-2.4.2}/setup.py +1 -1
  8. {diffindiff-2.4.1 → diffindiff-2.4.2}/MANIFEST.in +0 -0
  9. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/__init__.py +0 -0
  10. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/didanalysis.py +0 -0
  11. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/didtools.py +0 -0
  12. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/tests/__init__.py +0 -0
  13. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/tests/data/Corona_Hesse.xlsx +0 -0
  14. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/tests/data/counties_DE.csv +0 -0
  15. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/tests/data/curfew_DE.csv +0 -0
  16. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff/tests/tests_diffindiff.py +0 -0
  17. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff.egg-info/SOURCES.txt +0 -0
  18. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff.egg-info/dependency_links.txt +0 -0
  19. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff.egg-info/requires.txt +0 -0
  20. {diffindiff-2.4.1 → diffindiff-2.4.2}/diffindiff.egg-info/top_level.txt +0 -0
  21. {diffindiff-2.4.1 → diffindiff-2.4.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffindiff
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
@@ -29,7 +29,7 @@ A research note featuring a case study that utilizes the diffindiff library is a
29
29
 
30
30
  If you use this software, please cite:
31
31
 
32
- Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.4.1) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
32
+ Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.4.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
33
33
 
34
34
 
35
35
  ## Installation
@@ -177,7 +177,7 @@ See the /tests directory for usage examples of most of the included functions.
177
177
  This software was developed without the use of AI-generated code. The Continue Agent in Microsoft Visual Studio Code using the GPT-5 mini model (by OpenAI) was used solely to assist in drafting and refining docstrings for documentation. The corresponding guidelines and constraints defined by the author are documented in `AGENTS-docstrings.md` in the [public GitHub repository](https://github.com/geowieland/diffindiff_official).
178
178
 
179
179
 
180
- ## What's new (v2.4.1)
180
+ ## What's new (v2.4.2)
181
181
 
182
- - Other:
183
- - Extension of documentation
182
+ - Bugfixes:
183
+ - DiffData.add_own_counterfactual() now works correctly in any case
@@ -21,7 +21,7 @@ A research note featuring a case study that utilizes the diffindiff library is a
21
21
 
22
22
  If you use this software, please cite:
23
23
 
24
- Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.4.1) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
24
+ Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.4.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
25
25
 
26
26
 
27
27
  ## Installation
@@ -169,7 +169,7 @@ See the /tests directory for usage examples of most of the included functions.
169
169
  This software was developed without the use of AI-generated code. The Continue Agent in Microsoft Visual Studio Code using the GPT-5 mini model (by OpenAI) was used solely to assist in drafting and refining docstrings for documentation. The corresponding guidelines and constraints defined by the author are documented in `AGENTS-docstrings.md` in the [public GitHub repository](https://github.com/geowieland/diffindiff_official).
170
170
 
171
171
 
172
- ## What's new (v2.4.1)
172
+ ## What's new (v2.4.2)
173
173
 
174
- - Other:
175
- - Extension of documentation
174
+ - Bugfixes:
175
+ - DiffData.add_own_counterfactual() now works correctly in any case
@@ -4,15 +4,15 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 1.0.19
8
- # Last update: 2026-05-22 07:52
7
+ # Version: 1.0.20
8
+ # Last update: 2026-06-28 12:31
9
9
  # Copyright (c) 2025-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
  # Basic config:
13
13
 
14
14
  PACKAGE_NAME = "diffindiff"
15
- PACKAGE_VERSION = "2.4.1"
15
+ PACKAGE_VERSION = "2.4.2"
16
16
 
17
17
  VERBOSE = False
18
18
 
@@ -4,8 +4,8 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 1.2.0
8
- # Last update: 2025-05-01 09:28
7
+ # Version: 1.2.1
8
+ # Last update: 2025-06 28 13:03
9
9
  # Copyright (c) 2025-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
@@ -1547,16 +1547,19 @@ def extract_model_results(
1547
1547
  covariates_effects = {}
1548
1548
 
1549
1549
  for i, covariate in enumerate(covariates):
1550
- covariates_effects[i] = {
1551
- config.OLS_MODEL_RESULTS["coef_name"]["model_results_key"]: covariate,
1552
- config.OLS_MODEL_RESULTS["coef"]["model_results_key"]: coefficients[covariate],
1553
- "SE": float(coef_standarderrors[covariate]),
1554
- "t": float(coef_t[covariate]),
1555
- "p": float(coef_p[covariate]),
1556
- "CI_lower": float(coef_conf_intervals.loc[covariate, 0]),
1557
- "CI_upper": float(coef_conf_intervals.loc[covariate, 1]),
1558
- }
1559
-
1550
+
1551
+ if covariate in coefficients:
1552
+
1553
+ covariates_effects[i] = {
1554
+ config.OLS_MODEL_RESULTS["coef_name"]["model_results_key"]: covariate,
1555
+ config.OLS_MODEL_RESULTS["coef"]["model_results_key"]: coefficients[covariate],
1556
+ "SE": float(coef_standarderrors[covariate]),
1557
+ "t": float(coef_t[covariate]),
1558
+ "p": float(coef_p[covariate]),
1559
+ "CI_lower": float(coef_conf_intervals.loc[covariate, 0]),
1560
+ "CI_upper": float(coef_conf_intervals.loc[covariate, 1]),
1561
+ }
1562
+
1560
1563
  model_results["covariates_effects"] = covariates_effects
1561
1564
 
1562
1565
  if (len(TG_x_BG_x_TT_col) > 0) and (any(col in coefficients for col in TG_x_BG_x_TT_col)):
@@ -4,8 +4,8 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 2.2.6
8
- # Last update: 2026-04-30 21:19
7
+ # Version: 2.2.7
8
+ # Last update: 2026-06-28 13:18
9
9
  # Copyright (c) 2024-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
@@ -1647,39 +1647,64 @@ class DiffData:
1647
1647
  if time_col is None or counterfactual_outcome_col is None:
1648
1648
  raise ValueError("Parameters 'time_col' and 'counterfactual_outcome_col' must be stated")
1649
1649
 
1650
+ necessary_cols = [time_col, counterfactual_outcome_col]
1651
+ covariates = self.data[5]
1652
+ if len(covariates) > 0:
1653
+ necessary_cols.extend(covariates)
1654
+
1650
1655
  tools.check_columns(
1651
1656
  df = additional_df,
1652
- columns = [counterfactual_outcome_col, time_col]
1657
+ columns = necessary_cols
1653
1658
  )
1654
1659
 
1660
+ if verbose:
1661
+ print("Collecting treatment information", end = " ... ")
1662
+
1655
1663
  did_modeldata = self.data[0]
1656
- groups_data = self.data[1].get_data()
1664
+
1665
+ treatment_cols = self.get_treatment_cols()
1666
+ TG_col = treatment_cols[0]["TG_col"]
1667
+ TT_col = treatment_cols[0]["TT_col"]
1668
+ treatment_name = treatment_cols[0]["treatment_name"]
1669
+
1670
+ groups_data = self.data[1].get_data()
1657
1671
  groups_config = self.data[1].get_config()
1658
- treatment_group = groups_data.loc[groups_data[config.TG_COL] == 1, config.UNIT_COL].values
1659
- treatment_config = self.data[2].get_config()
1672
+
1673
+ treatment_group = did_modeldata.loc[did_modeldata[TG_col] == 1, config.UNIT_COL].values
1674
+
1675
+ treatment_config = self.data[2].get_config()
1676
+
1660
1677
  outcome_col_original = self.data[3]
1678
+
1661
1679
  treatment_data = self.data[2].get_data()
1662
1680
 
1663
- additional_df = additional_df[[time_col, counterfactual_outcome_col]].copy()
1681
+ additional_df = additional_df[necessary_cols].copy()
1682
+
1683
+ did_modeldata_TG = did_modeldata[did_modeldata[config.UNIT_COL].astype(str).isin(treatment_group)].copy()
1664
1684
 
1665
- did_modeldata_TG = did_modeldata[did_modeldata[config.UNIT_COL].astype(str).isin(treatment_group)].copy()
1685
+ if verbose:
1686
+ print("OK")
1687
+ print("Compiling and merging counterfactual data", end = " ... ")
1666
1688
 
1667
1689
  did_modeldata_counterfac = pd.DataFrame(columns=did_modeldata_TG.columns, index=range(len(treatment_data)))
1690
+
1668
1691
  did_modeldata_counterfac[config.UNIT_COL] = counterfactual_UID
1669
- did_modeldata_counterfac[config.TG_COL] = 0
1692
+ did_modeldata_counterfac[config.UNIT_COL] = did_modeldata_counterfac[config.UNIT_COL].astype(str)
1693
+
1694
+ did_modeldata_counterfac[TG_col] = 0
1695
+
1670
1696
  did_modeldata_counterfac[config.TIME_COL] = treatment_data[config.TIME_COL].values
1697
+ did_modeldata_counterfac[config.TIME_COL] = did_modeldata_counterfac[config.TIME_COL].astype(str)
1698
+
1671
1699
  did_modeldata_counterfac[config.TIME_COUNTER_COL] = treatment_data[config.TIME_COUNTER_COL].values
1672
- did_modeldata_counterfac[config.TT_COL] = treatment_data[config.TT_COL].values
1673
- did_modeldata_counterfac[config.TREATMENT_COL] = did_modeldata_counterfac[config.TG_COL] * did_modeldata_counterfac[config.TT_COL]
1674
-
1675
- did_modeldata_counterfac = tools.panel_index(
1676
- data=did_modeldata_counterfac,
1677
- unit_col=config.UNIT_COL,
1678
- time_col=config.TIME_COL,
1679
- verbose=verbose
1680
- )
1681
1700
 
1682
- if treatment_config["after_treatment_period"]:
1701
+ did_modeldata_counterfac[TT_col] = treatment_data[TT_col].values
1702
+
1703
+ did_modeldata_counterfac[treatment_name] = did_modeldata_counterfac[TG_col] * did_modeldata_counterfac[TT_col]
1704
+
1705
+ did_modeldata_counterfac[config.UNIT_TIME_COL] = did_modeldata_counterfac[config.UNIT_COL]+config.DELIMITER+did_modeldata_counterfac[config.TIME_COL]
1706
+
1707
+ if treatment_config[0]["after_treatment_period"]:
1683
1708
  did_modeldata_counterfac["ATT"] = treatment_data["ATT"].values
1684
1709
 
1685
1710
  if counterfactual_outcome_col == outcome_col_original:
@@ -1695,16 +1720,24 @@ class DiffData:
1695
1720
  )
1696
1721
 
1697
1722
  did_modeldata_counterfac[outcome_col_original] = did_modeldata_counterfac[counterfactual_outcome_col]
1698
- did_modeldata_counterfac = did_modeldata_counterfac.drop(counterfactual_outcome_col, axis = 1)
1723
+ did_modeldata_counterfac = did_modeldata_counterfac.drop(counterfactual_outcome_col, axis = 1)
1724
+
1725
+ if time_col in did_modeldata_counterfac.columns and time_col != config.TIME_COL:
1726
+ did_modeldata_counterfac = did_modeldata_counterfac.drop(time_col, axis = 1)
1699
1727
 
1700
1728
  did_modeldata_TG_with_counterfac = pd.concat(
1701
- [did_modeldata_TG, did_modeldata_counterfac],
1729
+ [
1730
+ did_modeldata_TG,
1731
+ did_modeldata_counterfac
1732
+ ],
1702
1733
  ignore_index=True
1703
1734
  )
1704
1735
 
1705
- groups_config["counterfactual"] = True
1706
-
1707
- groups_data = groups_data[groups_data[config.TG_COL] == 1]
1736
+ groups_config[0]["own_counterfactual"] = True
1737
+ groups_config[0]["control_group"] = 1
1738
+ groups_config[0]["full_sample"] = 2
1739
+
1740
+ groups_data = groups_data[0][groups_data[0][TG_col] == 1]
1708
1741
  groups_data_cf = {
1709
1742
  config.UNIT_COL: counterfactual_UID,
1710
1743
  config.TG_COL: 0
@@ -1719,6 +1752,9 @@ class DiffData:
1719
1752
 
1720
1753
  self.data[0] = did_modeldata_TG_with_counterfac
1721
1754
  self.data[1] = groups
1755
+
1756
+ if verbose:
1757
+ print("OK")
1722
1758
 
1723
1759
  return self
1724
1760
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffindiff
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: diffindiff: Python library for convenient Difference-in-Differences analyses
5
5
  Author: Thomas Wieland
6
6
  Author-email: geowieland@googlemail.com
@@ -29,7 +29,7 @@ A research note featuring a case study that utilizes the diffindiff library is a
29
29
 
30
30
  If you use this software, please cite:
31
31
 
32
- Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.4.1) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
32
+ Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.4.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
33
33
 
34
34
 
35
35
  ## Installation
@@ -177,7 +177,7 @@ See the /tests directory for usage examples of most of the included functions.
177
177
  This software was developed without the use of AI-generated code. The Continue Agent in Microsoft Visual Studio Code using the GPT-5 mini model (by OpenAI) was used solely to assist in drafting and refining docstrings for documentation. The corresponding guidelines and constraints defined by the author are documented in `AGENTS-docstrings.md` in the [public GitHub repository](https://github.com/geowieland/diffindiff_official).
178
178
 
179
179
 
180
- ## What's new (v2.4.1)
180
+ ## What's new (v2.4.2)
181
181
 
182
- - Other:
183
- - Extension of documentation
182
+ - Bugfixes:
183
+ - DiffData.add_own_counterfactual() now works correctly in any case
@@ -7,7 +7,7 @@ def read_README():
7
7
 
8
8
  setup(
9
9
  name='diffindiff',
10
- version='2.4.1',
10
+ version='2.4.2',
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