diffindiff 2.2.4__tar.gz → 2.2.6__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.2.4/diffindiff.egg-info → diffindiff-2.2.6}/PKG-INFO +55 -31
  2. diffindiff-2.2.4/PKG-INFO → diffindiff-2.2.6/README.md +53 -37
  3. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/config.py +5 -4
  4. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/didanalysis.py +4 -5
  5. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/didanalysis_helper.py +5 -6
  6. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/diddata.py +43 -22
  7. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/didtools.py +30 -5
  8. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/tests/tests_diffindiff.py +3 -3
  9. diffindiff-2.2.4/README.md → diffindiff-2.2.6/diffindiff.egg-info/PKG-INFO +61 -29
  10. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff.egg-info/requires.txt +0 -1
  11. {diffindiff-2.2.4 → diffindiff-2.2.6}/setup.py +3 -5
  12. {diffindiff-2.2.4 → diffindiff-2.2.6}/MANIFEST.in +0 -0
  13. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/__init__.py +0 -0
  14. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/tests/__init__.py +0 -0
  15. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/tests/data/Corona_Hesse.xlsx +0 -0
  16. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/tests/data/counties_DE.csv +0 -0
  17. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff/tests/data/curfew_DE.csv +0 -0
  18. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff.egg-info/SOURCES.txt +0 -0
  19. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff.egg-info/dependency_links.txt +0 -0
  20. {diffindiff-2.2.4 → diffindiff-2.2.6}/diffindiff.egg-info/top_level.txt +0 -0
  21. {diffindiff-2.2.4 → diffindiff-2.2.6}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffindiff
3
- Version: 2.2.4
4
- Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
3
+ Version: 2.2.6
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
8
 
9
- # diffindiff: Difference-in-Differences (DiD) Analysis Python Library
9
+ # diffindiff: Python library for convenient Difference-in-Differences analyses
10
10
 
11
11
  This Python library is designed for performing Difference-in-Differences (DiD) analyses in a convenient way. It allows users to construct datasets, define treatment and control groups, and set treatment periods. DiD model analyses may be conducted with both datasets created by built-in functions and ready-to-use external datasets. Both simultaneous and staggered adoption are supported. The library allows for various extensions, such as two-way fixed effects models, group- or individual-specific effects, post-treatment periods, and triple-difference estimations. Additionally, it includes functions for visualizing results, such as plotting DiD coefficients with confidence intervals and illustrating the temporal evolution of staggered treatments. Furthermore, several functions for rigorous treatment setting and data diagnostics are incorporated.
12
12
 
@@ -16,11 +16,33 @@ This Python library is designed for performing Difference-in-Differences (DiD) a
16
16
  Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geowieland@googlemail.com)
17
17
 
18
18
 
19
- ## Updates v2.2.4
20
- - Bugfixes:
21
- - Spillover treatment really really works now (only relevant in rare cases)
22
- - Fixed merging in diddata.DiffData.add_covariates() (only relevant in rare cases)
23
- - Dropping missing values consequently (only relevant in rare cases)
19
+ ## Availability
20
+
21
+ - 📦 PyPI: [diffindiff](https://pypi.org/project/diffindiff/)
22
+ - 💻 GitHub Repository: [diffindiff_official](https://github.com/geowieland/diffindiff_official)
23
+ - 📄 DOI (Zenodo): [10.5281/zenodo.18656820](https://doi.org/10.5281/zenodo.18656820)
24
+
25
+
26
+ ## Citation
27
+
28
+ If you use this software, please cite:
29
+
30
+ Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.2.6) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
31
+
32
+
33
+ ## Installation
34
+
35
+ To install the package, use `pip`:
36
+
37
+ ```bash
38
+ pip install diffindiff
39
+ ```
40
+
41
+ To install the package from GitHub with `pip`:
42
+
43
+ ```bash
44
+ pip install git+https://github.com/geowieland/diffindiff_official.git
45
+ ```
24
46
 
25
47
 
26
48
  ## Features
@@ -56,25 +78,6 @@ Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geo
56
78
  - Test for parallel trend assumption
57
79
 
58
80
 
59
- ## Literature
60
-
61
- - Baker AC, Larcker DF, Wang CCY (2022) How much should we trust staggered difference-in-differences estimates? *Journal of Financial Economics* 144(2): 370-395. [10.1016/j.jfineco.2022.01.004](https://doi.org/10.1016/j.jfineco.2022.01.004)
62
- - Card D, Krueger AD (1994) Minimum Wages and Employment: A Case Study of the Fast Food Industry in New Jersey and Pennsylvania. *The American Economic Review* 84(4): 772-793. [JSTOR](https://www.jstor.org/stable/2677856)
63
- - de Haas S, Götz G, Heim S (2022) Measuring the effect of COVID‑19‑related night curfews in a bundled intervention within Germany. *Scientific Reports* 12: 19732. [10.1038/s41598-022-24086-9](https://doi.org/10.1038/s41598-022-24086-9)
64
- - Goodman-Bacon A (2021) Difference-in-differences with variation in treatment timing. *Journal of Econometrics* 225(2): 254-277. [10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
65
- - Greene WH (2012) *Econometric Analysis*.
66
- - Goldfarb A, Tucker C, Wang Y (2022) Conducting Research in Marketing with Quasi-Experiments. *Journal of Marketing* 86(3): 1-19. [10.1177/00222429221082977](https://doi.org/10.1177/00222429221082977)
67
- - Isporhing IE, Lipfert M, Pestel N (2021) Does re-opening schools contribute to the spread of SARS-CoV-2? Evidence from staggered summer breaks in Germany. *Journal of Public Economics* 198: 104426. [10.1016/j.jpubeco.2021.104426](https://doi.org/10.1016/j.jpubeco.2021.104426)
68
- - Li KT, Luo L, Pattabhiramaiah A (2024) Causal Inference with Quasi-Experimental Data. *IMPACT at JMR* November 13, 2024. [AMA](https://www.ama.org/marketing-news/causal-inference-with-quasi-experimental-data/)
69
- - Olden A (2018) What do you buy when no one's watching? The effect of self-service checkouts on the composition of sales in retail. Discussion paper FOR 3/18, Norwegian School of Economics, Norway. [http://hdl.handle.net/11250/2490886](http://hdl.handle.net/11250/2490886)
70
- - Olden A, Moen J (2022) The triple difference estimator. *The Econometrics Journal* 25(3): 531-553. [10.1093/ectj/utac010](https://doi.org/10.1093/ectj/utac010)
71
- - Strassmann A, Çolak Y, Serra-Burriel M, Nordestgaard BG, Turk A, Afzal S, Puhan MA (2023) Nationwide indoor smoking ban and impact on smoking behaviour and lung function: a two-population natural experiment. *Thorax* 78(2): 144-150. [10.1136/thoraxjnl-2021-218436](https://doi.org/10.1136/thoraxjnl-2021-218436)
72
- - Villa JM (2016) diff: Simplifying the estimation of difference-in-differences treatment effects. *The Stata Journal* 16(1): 52-71. [10.1177/1536867X1601600108](https://doi.org/10.1177/1536867X1601600108)
73
- - von Bismarck-Osten C, Borusyak K, Schönberg U (2022) The role of schools in transmission of the SARS-CoV-2 virus: quasi-experimental evidence from Germany. *Economic Policy* 37(109): 87–130. [10.1093/epolic/eiac001](https://doi.org/10.1093/epolic/eiac001)
74
- - Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. *Journal of Public Health: From Theory to Practice* 33(11): 2497-2511. [10.1007/s10389-024-02218-x](https://doi.org/10.1007/s10389-024-02218-x)
75
- - Wooldridge JM (2012) *Introductory Econometrics. A Modern Approach*.
76
-
77
-
78
81
  ## Examples
79
82
 
80
83
  ```python
@@ -145,9 +148,30 @@ curfew_model_withgroups.plot_group_treatment_effects(
145
148
  See the /tests directory for usage examples of most of the included functions.
146
149
 
147
150
 
148
- ## Installation
151
+ ## Literature
149
152
 
150
- To install the package, use `pip`:
153
+ - Baker AC, Larcker DF, Wang CCY (2022) How much should we trust staggered difference-in-differences estimates? *Journal of Financial Economics* 144(2): 370-395. [10.1016/j.jfineco.2022.01.004](https://doi.org/10.1016/j.jfineco.2022.01.004)
154
+ - Card D, Krueger AD (1994) Minimum Wages and Employment: A Case Study of the Fast Food Industry in New Jersey and Pennsylvania. *The American Economic Review* 84(4): 772-793. [JSTOR](https://www.jstor.org/stable/2677856)
155
+ - de Haas S, Götz G, Heim S (2022) Measuring the effect of COVID‑19‑related night curfews in a bundled intervention within Germany. *Scientific Reports* 12: 19732. [10.1038/s41598-022-24086-9](https://doi.org/10.1038/s41598-022-24086-9)
156
+ - Goodman-Bacon A (2021) Difference-in-differences with variation in treatment timing. *Journal of Econometrics* 225(2): 254-277. [10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
157
+ - Greene WH (2012) *Econometric Analysis*.
158
+ - Goldfarb A, Tucker C, Wang Y (2022) Conducting Research in Marketing with Quasi-Experiments. *Journal of Marketing* 86(3): 1-19. [10.1177/00222429221082977](https://doi.org/10.1177/00222429221082977)
159
+ - Isporhing IE, Lipfert M, Pestel N (2021) Does re-opening schools contribute to the spread of SARS-CoV-2? Evidence from staggered summer breaks in Germany. *Journal of Public Economics* 198: 104426. [10.1016/j.jpubeco.2021.104426](https://doi.org/10.1016/j.jpubeco.2021.104426)
160
+ - Li KT, Luo L, Pattabhiramaiah A (2024) Causal Inference with Quasi-Experimental Data. *IMPACT at JMR* November 13, 2024. [AMA](https://www.ama.org/marketing-news/causal-inference-with-quasi-experimental-data/)
161
+ - Olden A (2018) What do you buy when no one's watching? The effect of self-service checkouts on the composition of sales in retail. Discussion paper FOR 3/18, Norwegian School of Economics, Norway. [http://hdl.handle.net/11250/2490886](http://hdl.handle.net/11250/2490886)
162
+ - Olden A, Moen J (2022) The triple difference estimator. *The Econometrics Journal* 25(3): 531-553. [10.1093/ectj/utac010](https://doi.org/10.1093/ectj/utac010)
163
+ - Strassmann A, Çolak Y, Serra-Burriel M, Nordestgaard BG, Turk A, Afzal S, Puhan MA (2023) Nationwide indoor smoking ban and impact on smoking behaviour and lung function: a two-population natural experiment. *Thorax* 78(2): 144-150. [10.1136/thoraxjnl-2021-218436](https://doi.org/10.1136/thoraxjnl-2021-218436)
164
+ - Villa JM (2016) diff: Simplifying the estimation of difference-in-differences treatment effects. *The Stata Journal* 16(1): 52-71. [10.1177/1536867X1601600108](https://doi.org/10.1177/1536867X1601600108)
165
+ - von Bismarck-Osten C, Borusyak K, Schönberg U (2022) The role of schools in transmission of the SARS-CoV-2 virus: quasi-experimental evidence from Germany. *Economic Policy* 37(109): 87–130. [10.1093/epolic/eiac001](https://doi.org/10.1093/epolic/eiac001)
166
+ - Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. *Journal of Public Health: From Theory to Practice* 33(11): 2497-2511. [10.1007/s10389-024-02218-x](https://doi.org/10.1007/s10389-024-02218-x)
167
+ - Wooldridge JM (2012) *Introductory Econometrics. A Modern Approach*.
168
+
169
+
170
+ ## What's new (v2.2.6)
171
+ - Bugfixes:
172
+ - Check for correct dates in diddata.create_treatment()
173
+ - Check for valid columns in diddata.merge_data()
174
+ - Removed unnecessary old dependencies and imports
175
+ - Other:
176
+ - Changed diddata.DiffGroups.add_segmentation() to return a message rather than raising an exception when the DiffGroups object already includes a benefit group
151
177
 
152
- ```bash
153
- pip install diffindiff
@@ -1,12 +1,4 @@
1
- Metadata-Version: 2.1
2
- Name: diffindiff
3
- Version: 2.2.4
4
- Summary: diffindiff: Python library for convenient Difference-in-Differences Analyses
5
- Author: Thomas Wieland
6
- Author-email: geowieland@googlemail.com
7
- Description-Content-Type: text/markdown
8
-
9
- # diffindiff: Difference-in-Differences (DiD) Analysis Python Library
1
+ # diffindiff: Python library for convenient Difference-in-Differences analyses
10
2
 
11
3
  This Python library is designed for performing Difference-in-Differences (DiD) analyses in a convenient way. It allows users to construct datasets, define treatment and control groups, and set treatment periods. DiD model analyses may be conducted with both datasets created by built-in functions and ready-to-use external datasets. Both simultaneous and staggered adoption are supported. The library allows for various extensions, such as two-way fixed effects models, group- or individual-specific effects, post-treatment periods, and triple-difference estimations. Additionally, it includes functions for visualizing results, such as plotting DiD coefficients with confidence intervals and illustrating the temporal evolution of staggered treatments. Furthermore, several functions for rigorous treatment setting and data diagnostics are incorporated.
12
4
 
@@ -16,11 +8,33 @@ This Python library is designed for performing Difference-in-Differences (DiD) a
16
8
  Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geowieland@googlemail.com)
17
9
 
18
10
 
19
- ## Updates v2.2.4
20
- - Bugfixes:
21
- - Spillover treatment really really works now (only relevant in rare cases)
22
- - Fixed merging in diddata.DiffData.add_covariates() (only relevant in rare cases)
23
- - Dropping missing values consequently (only relevant in rare cases)
11
+ ## Availability
12
+
13
+ - 📦 PyPI: [diffindiff](https://pypi.org/project/diffindiff/)
14
+ - 💻 GitHub Repository: [diffindiff_official](https://github.com/geowieland/diffindiff_official)
15
+ - 📄 DOI (Zenodo): [10.5281/zenodo.18656820](https://doi.org/10.5281/zenodo.18656820)
16
+
17
+
18
+ ## Citation
19
+
20
+ If you use this software, please cite:
21
+
22
+ Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.2.6) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
23
+
24
+
25
+ ## Installation
26
+
27
+ To install the package, use `pip`:
28
+
29
+ ```bash
30
+ pip install diffindiff
31
+ ```
32
+
33
+ To install the package from GitHub with `pip`:
34
+
35
+ ```bash
36
+ pip install git+https://github.com/geowieland/diffindiff_official.git
37
+ ```
24
38
 
25
39
 
26
40
  ## Features
@@ -56,25 +70,6 @@ Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geo
56
70
  - Test for parallel trend assumption
57
71
 
58
72
 
59
- ## Literature
60
-
61
- - Baker AC, Larcker DF, Wang CCY (2022) How much should we trust staggered difference-in-differences estimates? *Journal of Financial Economics* 144(2): 370-395. [10.1016/j.jfineco.2022.01.004](https://doi.org/10.1016/j.jfineco.2022.01.004)
62
- - Card D, Krueger AD (1994) Minimum Wages and Employment: A Case Study of the Fast Food Industry in New Jersey and Pennsylvania. *The American Economic Review* 84(4): 772-793. [JSTOR](https://www.jstor.org/stable/2677856)
63
- - de Haas S, Götz G, Heim S (2022) Measuring the effect of COVID‑19‑related night curfews in a bundled intervention within Germany. *Scientific Reports* 12: 19732. [10.1038/s41598-022-24086-9](https://doi.org/10.1038/s41598-022-24086-9)
64
- - Goodman-Bacon A (2021) Difference-in-differences with variation in treatment timing. *Journal of Econometrics* 225(2): 254-277. [10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
65
- - Greene WH (2012) *Econometric Analysis*.
66
- - Goldfarb A, Tucker C, Wang Y (2022) Conducting Research in Marketing with Quasi-Experiments. *Journal of Marketing* 86(3): 1-19. [10.1177/00222429221082977](https://doi.org/10.1177/00222429221082977)
67
- - Isporhing IE, Lipfert M, Pestel N (2021) Does re-opening schools contribute to the spread of SARS-CoV-2? Evidence from staggered summer breaks in Germany. *Journal of Public Economics* 198: 104426. [10.1016/j.jpubeco.2021.104426](https://doi.org/10.1016/j.jpubeco.2021.104426)
68
- - Li KT, Luo L, Pattabhiramaiah A (2024) Causal Inference with Quasi-Experimental Data. *IMPACT at JMR* November 13, 2024. [AMA](https://www.ama.org/marketing-news/causal-inference-with-quasi-experimental-data/)
69
- - Olden A (2018) What do you buy when no one's watching? The effect of self-service checkouts on the composition of sales in retail. Discussion paper FOR 3/18, Norwegian School of Economics, Norway. [http://hdl.handle.net/11250/2490886](http://hdl.handle.net/11250/2490886)
70
- - Olden A, Moen J (2022) The triple difference estimator. *The Econometrics Journal* 25(3): 531-553. [10.1093/ectj/utac010](https://doi.org/10.1093/ectj/utac010)
71
- - Strassmann A, Çolak Y, Serra-Burriel M, Nordestgaard BG, Turk A, Afzal S, Puhan MA (2023) Nationwide indoor smoking ban and impact on smoking behaviour and lung function: a two-population natural experiment. *Thorax* 78(2): 144-150. [10.1136/thoraxjnl-2021-218436](https://doi.org/10.1136/thoraxjnl-2021-218436)
72
- - Villa JM (2016) diff: Simplifying the estimation of difference-in-differences treatment effects. *The Stata Journal* 16(1): 52-71. [10.1177/1536867X1601600108](https://doi.org/10.1177/1536867X1601600108)
73
- - von Bismarck-Osten C, Borusyak K, Schönberg U (2022) The role of schools in transmission of the SARS-CoV-2 virus: quasi-experimental evidence from Germany. *Economic Policy* 37(109): 87–130. [10.1093/epolic/eiac001](https://doi.org/10.1093/epolic/eiac001)
74
- - Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. *Journal of Public Health: From Theory to Practice* 33(11): 2497-2511. [10.1007/s10389-024-02218-x](https://doi.org/10.1007/s10389-024-02218-x)
75
- - Wooldridge JM (2012) *Introductory Econometrics. A Modern Approach*.
76
-
77
-
78
73
  ## Examples
79
74
 
80
75
  ```python
@@ -145,9 +140,30 @@ curfew_model_withgroups.plot_group_treatment_effects(
145
140
  See the /tests directory for usage examples of most of the included functions.
146
141
 
147
142
 
148
- ## Installation
143
+ ## Literature
149
144
 
150
- To install the package, use `pip`:
145
+ - Baker AC, Larcker DF, Wang CCY (2022) How much should we trust staggered difference-in-differences estimates? *Journal of Financial Economics* 144(2): 370-395. [10.1016/j.jfineco.2022.01.004](https://doi.org/10.1016/j.jfineco.2022.01.004)
146
+ - Card D, Krueger AD (1994) Minimum Wages and Employment: A Case Study of the Fast Food Industry in New Jersey and Pennsylvania. *The American Economic Review* 84(4): 772-793. [JSTOR](https://www.jstor.org/stable/2677856)
147
+ - de Haas S, Götz G, Heim S (2022) Measuring the effect of COVID‑19‑related night curfews in a bundled intervention within Germany. *Scientific Reports* 12: 19732. [10.1038/s41598-022-24086-9](https://doi.org/10.1038/s41598-022-24086-9)
148
+ - Goodman-Bacon A (2021) Difference-in-differences with variation in treatment timing. *Journal of Econometrics* 225(2): 254-277. [10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
149
+ - Greene WH (2012) *Econometric Analysis*.
150
+ - Goldfarb A, Tucker C, Wang Y (2022) Conducting Research in Marketing with Quasi-Experiments. *Journal of Marketing* 86(3): 1-19. [10.1177/00222429221082977](https://doi.org/10.1177/00222429221082977)
151
+ - Isporhing IE, Lipfert M, Pestel N (2021) Does re-opening schools contribute to the spread of SARS-CoV-2? Evidence from staggered summer breaks in Germany. *Journal of Public Economics* 198: 104426. [10.1016/j.jpubeco.2021.104426](https://doi.org/10.1016/j.jpubeco.2021.104426)
152
+ - Li KT, Luo L, Pattabhiramaiah A (2024) Causal Inference with Quasi-Experimental Data. *IMPACT at JMR* November 13, 2024. [AMA](https://www.ama.org/marketing-news/causal-inference-with-quasi-experimental-data/)
153
+ - Olden A (2018) What do you buy when no one's watching? The effect of self-service checkouts on the composition of sales in retail. Discussion paper FOR 3/18, Norwegian School of Economics, Norway. [http://hdl.handle.net/11250/2490886](http://hdl.handle.net/11250/2490886)
154
+ - Olden A, Moen J (2022) The triple difference estimator. *The Econometrics Journal* 25(3): 531-553. [10.1093/ectj/utac010](https://doi.org/10.1093/ectj/utac010)
155
+ - Strassmann A, Çolak Y, Serra-Burriel M, Nordestgaard BG, Turk A, Afzal S, Puhan MA (2023) Nationwide indoor smoking ban and impact on smoking behaviour and lung function: a two-population natural experiment. *Thorax* 78(2): 144-150. [10.1136/thoraxjnl-2021-218436](https://doi.org/10.1136/thoraxjnl-2021-218436)
156
+ - Villa JM (2016) diff: Simplifying the estimation of difference-in-differences treatment effects. *The Stata Journal* 16(1): 52-71. [10.1177/1536867X1601600108](https://doi.org/10.1177/1536867X1601600108)
157
+ - von Bismarck-Osten C, Borusyak K, Schönberg U (2022) The role of schools in transmission of the SARS-CoV-2 virus: quasi-experimental evidence from Germany. *Economic Policy* 37(109): 87–130. [10.1093/epolic/eiac001](https://doi.org/10.1093/epolic/eiac001)
158
+ - Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. *Journal of Public Health: From Theory to Practice* 33(11): 2497-2511. [10.1007/s10389-024-02218-x](https://doi.org/10.1007/s10389-024-02218-x)
159
+ - Wooldridge JM (2012) *Introductory Econometrics. A Modern Approach*.
160
+
161
+
162
+ ## What's new (v2.2.6)
163
+ - Bugfixes:
164
+ - Check for correct dates in diddata.create_treatment()
165
+ - Check for valid columns in diddata.merge_data()
166
+ - Removed unnecessary old dependencies and imports
167
+ - Other:
168
+ - Changed diddata.DiffGroups.add_segmentation() to return a message rather than raising an exception when the DiffGroups object already includes a benefit group
151
169
 
152
- ```bash
153
- pip install diffindiff
@@ -4,14 +4,15 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 1.0.4
8
- # Last update: 2025-12-06 11:52
9
- # Copyright (c) 2025 Thomas Wieland
7
+ # Version: 1.0.5
8
+ # Last update: 2026-02-20 17:30
9
+ # Copyright (c) 2025-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
  # Basic config:
13
13
 
14
- PACKAGE_VERSION = "2.2.2"
14
+ PACKAGE_NAME = "diffindiff"
15
+ PACKAGE_VERSION = "2.2.6"
15
16
 
16
17
  VERBOSE = False
17
18
 
@@ -4,15 +4,14 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 2.2.2
8
- # Last update: 2025-12-07 10:27
9
- # Copyright (c) 2025 Thomas Wieland
7
+ # Version: 2.2.3
8
+ # Last update: 2026-02-20 17:42
9
+ # Copyright (c) 2024-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
 
13
13
  import pandas as pd
14
14
  import numpy as np
15
- from math import isnan
16
15
  import matplotlib.pyplot as plt
17
16
  from matplotlib.dates import DateFormatter
18
17
  import diffindiff.didtools as tools
@@ -930,7 +929,7 @@ class DiffModel:
930
929
  if "TG" in plot_intervals_groups and "CG" in plot_intervals_groups:
931
930
  lines_labels_required = lines_labels_required+2
932
931
  assert len(lines_col) == lines_col_required, f"Parameter 'lines_col' must be a list with {lines_col_required} entries"
933
- assert len(lines_style) == lines_style_required, f"Parameter 'lines_style' must be a list with {lines_col_required} entries"
932
+ assert len(lines_style) == lines_style_required, f"Parameter 'lines_style' must be a list with {lines_style_required} entries"
934
933
  assert len(lines_labels) == lines_labels_required, f"Parameter 'lines_labels' must be a list with {lines_labels_required} entries"
935
934
 
936
935
  model_data = self.data[2]
@@ -4,9 +4,9 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 1.0.5
8
- # Last update: 2025-12-07 10:27
9
- # Copyright (c) 2025 Thomas Wieland
7
+ # Version: 1.0.6
8
+ # Last update: 2025-02-20 17:38
9
+ # Copyright (c) 2025-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
  import pandas as pd
@@ -918,10 +918,9 @@ def create_timestamp(function):
918
918
  now = datetime.now()
919
919
 
920
920
  timestamp_dict = {
921
- "package_version": f"diffindiff {config.PACKAGE_VERSION}",
921
+ "package_version": f"{config.PACKAGE_NAME} {config.PACKAGE_VERSION}",
922
922
  "function": function,
923
923
  "datetime": now.strftime("%Y-%m-%d %H-%M-%S")
924
924
  }
925
925
 
926
- return timestamp_dict
927
-
926
+ return timestamp_dict
@@ -4,9 +4,9 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 2.1.5
8
- # Last update: 2025-12-07 10:27
9
- # Copyright (c) 2025 Thomas Wieland
7
+ # Version: 2.1.6
8
+ # Last update: 2026-02-20 18:28
9
+ # Copyright (c) 2024-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
 
@@ -76,29 +76,34 @@ class DiffGroups:
76
76
  verbose: bool = config.VERBOSE
77
77
  ):
78
78
 
79
- groups_config = self.data[1]
79
+ groups_config = self.data[1]
80
80
 
81
81
  if groups_config["DDD"]:
82
- raise ValueError("DiffGroups object already includes a benefit group")
83
-
84
- if verbose:
85
- print(f"Adding benefit group with {len(group_benefit)} units to groups data", end = " ... ")
86
-
87
- groups_data = self.data[0]
82
+
83
+ print("DiffGroups object already includes a benefit group. No segmentation added.")
84
+
85
+ groups = self
86
+
87
+ else:
88
88
 
89
- groups_data[config.BG_COL] = 0
90
- groups_data.loc[groups_data[config.UNIT_COL].astype(str).isin(group_benefit), config.BG_COL] = 1
91
-
92
- groups_config["DDD"] = True
89
+ if verbose:
90
+ print(f"Adding benefit group with {len(group_benefit)} units to groups data", end = " ... ")
91
+
92
+ groups_data = self.data[0]
93
+
94
+ groups_data[config.BG_COL] = 0
95
+ groups_data.loc[groups_data[config.UNIT_COL].astype(str).isin(group_benefit), config.BG_COL] = 1
96
+
97
+ groups_config["DDD"] = True
93
98
 
94
- groups = DiffGroups(
95
- groups_data,
96
- groups_config,
97
- timestamp = helper.create_timestamp(function="add_segmentation")
98
- )
99
+ groups = DiffGroups(
100
+ groups_data,
101
+ groups_config,
102
+ timestamp = helper.create_timestamp(function="add_segmentation")
103
+ )
99
104
 
100
- if verbose:
101
- print("OK")
105
+ if verbose:
106
+ print("OK")
102
107
 
103
108
  return groups
104
109
 
@@ -255,9 +260,16 @@ def create_treatment(
255
260
  after_treatment_period: bool = False,
256
261
  verbose = config.VERBOSE
257
262
  ):
263
+
264
+ check_dates = tools.check_date_format(
265
+ dates = study_period+treatment_period,
266
+ date_format = date_format
267
+ )
268
+ if check_dates[0]:
269
+ raise ValueError(f"Study and/or treatment period include invalid dates: {', '.join(check_dates[1])}.")
258
270
 
259
271
  TT_col = config.TT_COL
260
-
272
+
261
273
  if treatment_name is not None:
262
274
 
263
275
  if not isinstance(treatment_name, str):
@@ -1016,6 +1028,15 @@ def merge_data(
1016
1028
  keep_columns: bool = False,
1017
1029
  verbose: bool = config.VERBOSE
1018
1030
  ):
1031
+
1032
+ tools.check_columns(
1033
+ df = outcome_data,
1034
+ columns = [
1035
+ unit_id_col,
1036
+ time_col,
1037
+ outcome_col
1038
+ ]
1039
+ )
1019
1040
 
1020
1041
  if verbose:
1021
1042
  print("Merging groups and treatment data", end = " ... ")
@@ -4,15 +4,16 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 2.1.4
8
- # Last update: 2025-12-07 10:27
9
- # Copyright (c) 2025 Thomas Wieland
7
+ # Version: 2.1.5
8
+ # Last update: 2026-02-20 17:43
9
+ # Copyright (c) 2025-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
 
13
13
  import pandas as pd
14
14
  import numpy as np
15
15
  import re
16
+ from datetime import datetime
16
17
  from collections.abc import Iterable
17
18
  from statsmodels.formula.api import ols
18
19
  from sklearn.ensemble import BaggingRegressor, RandomForestRegressor, GradientBoostingRegressor
@@ -23,7 +24,6 @@ from xgboost import XGBRegressor
23
24
  from lightgbm import LGBMRegressor
24
25
  from sklearn.linear_model import LinearRegression
25
26
  from sklearn.model_selection import train_test_split
26
- from huff.goodness_of_fit import modelfit, modelfit_cat, modelfit_plot
27
27
  import diffindiff.config as config
28
28
 
29
29
 
@@ -947,4 +947,29 @@ def bool_to_YN(val):
947
947
  if isinstance(val, bool):
948
948
  return "YES" if val else "NO"
949
949
  else:
950
- return val
950
+ return val
951
+
952
+ def check_date_format(
953
+ dates: list = None,
954
+ date_format: str = "%Y-%m-%d"
955
+ ):
956
+
957
+ if dates is None:
958
+ dates = []
959
+
960
+ invalid_dates_included = False
961
+ invalid_dates = []
962
+
963
+ for date in dates:
964
+ try:
965
+ datetime.strptime(date, date_format)
966
+ except (ValueError, TypeError):
967
+ invalid_dates.append(date)
968
+
969
+ if len(invalid_dates) > 0:
970
+ invalid_dates_included = True
971
+
972
+ return [
973
+ invalid_dates_included,
974
+ invalid_dates
975
+ ]
@@ -4,9 +4,9 @@
4
4
  # Author: Thomas Wieland
5
5
  # ORCID: 0000-0001-5168-9846
6
6
  # mail: geowieland@googlemail.com
7
- # Version: 2.0.10
8
- # Last update: 2025-12-05 17:23
9
- # Copyright (c) 2025 Thomas Wieland
7
+ # Version: 2.0.11
8
+ # Last update: 2026-02-20 17:44
9
+ # Copyright (c) 2025-2026 Thomas Wieland
10
10
  #-----------------------------------------------------------------------
11
11
 
12
12
 
@@ -1,4 +1,12 @@
1
- # diffindiff: Difference-in-Differences (DiD) Analysis Python Library
1
+ Metadata-Version: 2.1
2
+ Name: diffindiff
3
+ Version: 2.2.6
4
+ Summary: diffindiff: Python library for convenient Difference-in-Differences analyses
5
+ Author: Thomas Wieland
6
+ Author-email: geowieland@googlemail.com
7
+ Description-Content-Type: text/markdown
8
+
9
+ # diffindiff: Python library for convenient Difference-in-Differences analyses
2
10
 
3
11
  This Python library is designed for performing Difference-in-Differences (DiD) analyses in a convenient way. It allows users to construct datasets, define treatment and control groups, and set treatment periods. DiD model analyses may be conducted with both datasets created by built-in functions and ready-to-use external datasets. Both simultaneous and staggered adoption are supported. The library allows for various extensions, such as two-way fixed effects models, group- or individual-specific effects, post-treatment periods, and triple-difference estimations. Additionally, it includes functions for visualizing results, such as plotting DiD coefficients with confidence intervals and illustrating the temporal evolution of staggered treatments. Furthermore, several functions for rigorous treatment setting and data diagnostics are incorporated.
4
12
 
@@ -8,11 +16,33 @@ This Python library is designed for performing Difference-in-Differences (DiD) a
8
16
  Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geowieland@googlemail.com)
9
17
 
10
18
 
11
- ## Updates v2.2.4
12
- - Bugfixes:
13
- - Spillover treatment really really works now (only relevant in rare cases)
14
- - Fixed merging in diddata.DiffData.add_covariates() (only relevant in rare cases)
15
- - Dropping missing values consequently (only relevant in rare cases)
19
+ ## Availability
20
+
21
+ - 📦 PyPI: [diffindiff](https://pypi.org/project/diffindiff/)
22
+ - 💻 GitHub Repository: [diffindiff_official](https://github.com/geowieland/diffindiff_official)
23
+ - 📄 DOI (Zenodo): [10.5281/zenodo.18656820](https://doi.org/10.5281/zenodo.18656820)
24
+
25
+
26
+ ## Citation
27
+
28
+ If you use this software, please cite:
29
+
30
+ Wieland, T. (2026). diffindiff: A Python library for convenient difference-in-differences analyses (Version 2.2.6) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.18656820
31
+
32
+
33
+ ## Installation
34
+
35
+ To install the package, use `pip`:
36
+
37
+ ```bash
38
+ pip install diffindiff
39
+ ```
40
+
41
+ To install the package from GitHub with `pip`:
42
+
43
+ ```bash
44
+ pip install git+https://github.com/geowieland/diffindiff_official.git
45
+ ```
16
46
 
17
47
 
18
48
  ## Features
@@ -48,25 +78,6 @@ Thomas Wieland [ORCID](https://orcid.org/0000-0001-5168-9846) [EMail](mailto:geo
48
78
  - Test for parallel trend assumption
49
79
 
50
80
 
51
- ## Literature
52
-
53
- - Baker AC, Larcker DF, Wang CCY (2022) How much should we trust staggered difference-in-differences estimates? *Journal of Financial Economics* 144(2): 370-395. [10.1016/j.jfineco.2022.01.004](https://doi.org/10.1016/j.jfineco.2022.01.004)
54
- - Card D, Krueger AD (1994) Minimum Wages and Employment: A Case Study of the Fast Food Industry in New Jersey and Pennsylvania. *The American Economic Review* 84(4): 772-793. [JSTOR](https://www.jstor.org/stable/2677856)
55
- - de Haas S, Götz G, Heim S (2022) Measuring the effect of COVID‑19‑related night curfews in a bundled intervention within Germany. *Scientific Reports* 12: 19732. [10.1038/s41598-022-24086-9](https://doi.org/10.1038/s41598-022-24086-9)
56
- - Goodman-Bacon A (2021) Difference-in-differences with variation in treatment timing. *Journal of Econometrics* 225(2): 254-277. [10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
57
- - Greene WH (2012) *Econometric Analysis*.
58
- - Goldfarb A, Tucker C, Wang Y (2022) Conducting Research in Marketing with Quasi-Experiments. *Journal of Marketing* 86(3): 1-19. [10.1177/00222429221082977](https://doi.org/10.1177/00222429221082977)
59
- - Isporhing IE, Lipfert M, Pestel N (2021) Does re-opening schools contribute to the spread of SARS-CoV-2? Evidence from staggered summer breaks in Germany. *Journal of Public Economics* 198: 104426. [10.1016/j.jpubeco.2021.104426](https://doi.org/10.1016/j.jpubeco.2021.104426)
60
- - Li KT, Luo L, Pattabhiramaiah A (2024) Causal Inference with Quasi-Experimental Data. *IMPACT at JMR* November 13, 2024. [AMA](https://www.ama.org/marketing-news/causal-inference-with-quasi-experimental-data/)
61
- - Olden A (2018) What do you buy when no one's watching? The effect of self-service checkouts on the composition of sales in retail. Discussion paper FOR 3/18, Norwegian School of Economics, Norway. [http://hdl.handle.net/11250/2490886](http://hdl.handle.net/11250/2490886)
62
- - Olden A, Moen J (2022) The triple difference estimator. *The Econometrics Journal* 25(3): 531-553. [10.1093/ectj/utac010](https://doi.org/10.1093/ectj/utac010)
63
- - Strassmann A, Çolak Y, Serra-Burriel M, Nordestgaard BG, Turk A, Afzal S, Puhan MA (2023) Nationwide indoor smoking ban and impact on smoking behaviour and lung function: a two-population natural experiment. *Thorax* 78(2): 144-150. [10.1136/thoraxjnl-2021-218436](https://doi.org/10.1136/thoraxjnl-2021-218436)
64
- - Villa JM (2016) diff: Simplifying the estimation of difference-in-differences treatment effects. *The Stata Journal* 16(1): 52-71. [10.1177/1536867X1601600108](https://doi.org/10.1177/1536867X1601600108)
65
- - von Bismarck-Osten C, Borusyak K, Schönberg U (2022) The role of schools in transmission of the SARS-CoV-2 virus: quasi-experimental evidence from Germany. *Economic Policy* 37(109): 87–130. [10.1093/epolic/eiac001](https://doi.org/10.1093/epolic/eiac001)
66
- - Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. *Journal of Public Health: From Theory to Practice* 33(11): 2497-2511. [10.1007/s10389-024-02218-x](https://doi.org/10.1007/s10389-024-02218-x)
67
- - Wooldridge JM (2012) *Introductory Econometrics. A Modern Approach*.
68
-
69
-
70
81
  ## Examples
71
82
 
72
83
  ```python
@@ -137,9 +148,30 @@ curfew_model_withgroups.plot_group_treatment_effects(
137
148
  See the /tests directory for usage examples of most of the included functions.
138
149
 
139
150
 
140
- ## Installation
151
+ ## Literature
141
152
 
142
- To install the package, use `pip`:
153
+ - Baker AC, Larcker DF, Wang CCY (2022) How much should we trust staggered difference-in-differences estimates? *Journal of Financial Economics* 144(2): 370-395. [10.1016/j.jfineco.2022.01.004](https://doi.org/10.1016/j.jfineco.2022.01.004)
154
+ - Card D, Krueger AD (1994) Minimum Wages and Employment: A Case Study of the Fast Food Industry in New Jersey and Pennsylvania. *The American Economic Review* 84(4): 772-793. [JSTOR](https://www.jstor.org/stable/2677856)
155
+ - de Haas S, Götz G, Heim S (2022) Measuring the effect of COVID‑19‑related night curfews in a bundled intervention within Germany. *Scientific Reports* 12: 19732. [10.1038/s41598-022-24086-9](https://doi.org/10.1038/s41598-022-24086-9)
156
+ - Goodman-Bacon A (2021) Difference-in-differences with variation in treatment timing. *Journal of Econometrics* 225(2): 254-277. [10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
157
+ - Greene WH (2012) *Econometric Analysis*.
158
+ - Goldfarb A, Tucker C, Wang Y (2022) Conducting Research in Marketing with Quasi-Experiments. *Journal of Marketing* 86(3): 1-19. [10.1177/00222429221082977](https://doi.org/10.1177/00222429221082977)
159
+ - Isporhing IE, Lipfert M, Pestel N (2021) Does re-opening schools contribute to the spread of SARS-CoV-2? Evidence from staggered summer breaks in Germany. *Journal of Public Economics* 198: 104426. [10.1016/j.jpubeco.2021.104426](https://doi.org/10.1016/j.jpubeco.2021.104426)
160
+ - Li KT, Luo L, Pattabhiramaiah A (2024) Causal Inference with Quasi-Experimental Data. *IMPACT at JMR* November 13, 2024. [AMA](https://www.ama.org/marketing-news/causal-inference-with-quasi-experimental-data/)
161
+ - Olden A (2018) What do you buy when no one's watching? The effect of self-service checkouts on the composition of sales in retail. Discussion paper FOR 3/18, Norwegian School of Economics, Norway. [http://hdl.handle.net/11250/2490886](http://hdl.handle.net/11250/2490886)
162
+ - Olden A, Moen J (2022) The triple difference estimator. *The Econometrics Journal* 25(3): 531-553. [10.1093/ectj/utac010](https://doi.org/10.1093/ectj/utac010)
163
+ - Strassmann A, Çolak Y, Serra-Burriel M, Nordestgaard BG, Turk A, Afzal S, Puhan MA (2023) Nationwide indoor smoking ban and impact on smoking behaviour and lung function: a two-population natural experiment. *Thorax* 78(2): 144-150. [10.1136/thoraxjnl-2021-218436](https://doi.org/10.1136/thoraxjnl-2021-218436)
164
+ - Villa JM (2016) diff: Simplifying the estimation of difference-in-differences treatment effects. *The Stata Journal* 16(1): 52-71. [10.1177/1536867X1601600108](https://doi.org/10.1177/1536867X1601600108)
165
+ - von Bismarck-Osten C, Borusyak K, Schönberg U (2022) The role of schools in transmission of the SARS-CoV-2 virus: quasi-experimental evidence from Germany. *Economic Policy* 37(109): 87–130. [10.1093/epolic/eiac001](https://doi.org/10.1093/epolic/eiac001)
166
+ - Wieland T (2025) Assessing the effectiveness of non-pharmaceutical interventions in the SARS-CoV-2 pandemic: results of a natural experiment regarding Baden-Württemberg (Germany) and Switzerland in the second infection wave. *Journal of Public Health: From Theory to Practice* 33(11): 2497-2511. [10.1007/s10389-024-02218-x](https://doi.org/10.1007/s10389-024-02218-x)
167
+ - Wooldridge JM (2012) *Introductory Econometrics. A Modern Approach*.
168
+
169
+
170
+ ## What's new (v2.2.6)
171
+ - Bugfixes:
172
+ - Check for correct dates in diddata.create_treatment()
173
+ - Check for valid columns in diddata.merge_data()
174
+ - Removed unnecessary old dependencies and imports
175
+ - Other:
176
+ - Changed diddata.DiffGroups.add_segmentation() to return a message rather than raising an exception when the DiffGroups object already includes a benefit group
143
177
 
144
- ```bash
145
- pip install diffindiff
@@ -9,4 +9,3 @@ xgboost
9
9
  lightgbm
10
10
  patsy
11
11
  openpyxl
12
- huff>=1.6.6
@@ -1,6 +1,5 @@
1
1
  from setuptools import setup, find_packages
2
2
  import os
3
- import diffindiff.config as config
4
3
 
5
4
  def read_README():
6
5
  with open(os.path.join(os.path.dirname(__file__), 'README.md'), encoding='utf-8') as f:
@@ -8,8 +7,8 @@ def read_README():
8
7
 
9
8
  setup(
10
9
  name='diffindiff',
11
- version='2.2.4',
12
- description='diffindiff: Python library for convenient Difference-in-Differences Analyses',
10
+ version='2.2.6',
11
+ description='diffindiff: Python library for convenient Difference-in-Differences analyses',
13
12
  packages=find_packages(include=["diffindiff", "diffindiff.tests"]),
14
13
  include_package_data=True,
15
14
  long_description=read_README(),
@@ -31,8 +30,7 @@ setup(
31
30
  'xgboost',
32
31
  'lightgbm',
33
32
  'patsy',
34
- 'openpyxl',
35
- 'huff>=1.6.6'
33
+ 'openpyxl'
36
34
  ],
37
35
  test_suite='tests',
38
36
  )
File without changes
File without changes