Skip to content

Commit 9063cbd

Browse files
MaxGhenisclaude
andcommitted
Fix CI issues
- Update gini.ipynb to use MicroSeries.gini() instead of removed mdf.gini() - Add missing newlines to __init__.py and changelog_entry.yaml 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd9de44 commit 9063cbd

3 files changed

Lines changed: 32 additions & 168 deletions

File tree

changelog_entry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
- Remove agg, concat, constants, custom_taxes, income_measures, inequality (standalone functions), io, poverty (standalone functions), tax, ubi, utils, and weighted modules.
77
- Remove _optional module as it's no longer needed.
88
- Remove associated test files for deleted modules.
9-
- Simplify package to focus on core weighted data structures used by PolicyEngine.
9+
- Simplify package to focus on core weighted data structures used by PolicyEngine.

docs/gini.ipynb

Lines changed: 30 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# `gini` example"
7+
"# `gini` example using MicroSeries"
88
]
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 1,
12+
"execution_count": null,
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
1616
"import microdf as mdf\n",
17-
"\n",
18-
"import pandas as pd"
17+
"import pandas as pd\n",
18+
"import numpy as np"
1919
]
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 2,
23+
"execution_count": null,
2424
"metadata": {},
2525
"outputs": [],
2626
"source": [
27-
"x = [-10, -1, 0, 5, 100]\n",
27+
"# Create sample data\n",
28+
"x = [10, 20, 30, 40, 100]\n",
2829
"w = [1, 2, 3, 4, 5]\n",
2930
"df = pd.DataFrame({'x': x, 'w': w})"
3031
]
@@ -33,180 +34,56 @@
3334
"cell_type": "markdown",
3435
"metadata": {},
3536
"source": [
36-
"## Simple behavior"
37-
]
38-
},
39-
{
40-
"cell_type": "code",
41-
"execution_count": 3,
42-
"metadata": {},
43-
"outputs": [
44-
{
45-
"data": {
46-
"text/plain": [
47-
"0.9617021276595745"
48-
]
49-
},
50-
"execution_count": 3,
51-
"metadata": {},
52-
"output_type": "execute_result"
53-
}
54-
],
55-
"source": [
56-
"mdf.gini(df, 'x')"
57-
]
58-
},
59-
{
60-
"cell_type": "markdown",
61-
"metadata": {},
62-
"source": [
63-
"## Dealing with negatives"
64-
]
65-
},
66-
{
67-
"cell_type": "markdown",
68-
"metadata": {},
69-
"source": [
70-
"This will be equivalent to `mdf.gini(pd.DataFrame({'x': [0, 0, 0, 5, 100]}))`."
71-
]
72-
},
73-
{
74-
"cell_type": "code",
75-
"execution_count": 4,
76-
"metadata": {},
77-
"outputs": [
78-
{
79-
"data": {
80-
"text/plain": [
81-
"0.780952380952381"
82-
]
83-
},
84-
"execution_count": 4,
85-
"metadata": {},
86-
"output_type": "execute_result"
87-
}
88-
],
89-
"source": [
90-
"mdf.gini(df, 'x', negatives='zero')"
37+
"## Using MicroSeries.gini()"
9138
]
9239
},
9340
{
9441
"cell_type": "code",
95-
"execution_count": 5,
42+
"execution_count": null,
9643
"metadata": {},
97-
"outputs": [
98-
{
99-
"data": {
100-
"text/plain": [
101-
"0.780952380952381"
102-
]
103-
},
104-
"execution_count": 5,
105-
"metadata": {},
106-
"output_type": "execute_result"
107-
}
108-
],
44+
"outputs": [],
10945
"source": [
110-
"mdf.gini(pd.DataFrame({'x': [0, 0, 0, 5, 100]}), 'x')"
46+
"# Create a MicroSeries with weights\n",
47+
"ms = mdf.MicroSeries(df.x, weights=df.w)\n",
48+
"print(f\"Gini coefficient: {ms.gini():.4f}\")"
11149
]
11250
},
11351
{
11452
"cell_type": "markdown",
11553
"metadata": {},
11654
"source": [
117-
"This will be equivalent to `mdf.gini(pd.DataFrame({'x': [0, 9, 10, 15, 110]}))`."
118-
]
119-
},
120-
{
121-
"cell_type": "code",
122-
"execution_count": 6,
123-
"metadata": {},
124-
"outputs": [
125-
{
126-
"data": {
127-
"text/plain": [
128-
"0.6277777777777778"
129-
]
130-
},
131-
"execution_count": 6,
132-
"metadata": {},
133-
"output_type": "execute_result"
134-
}
135-
],
136-
"source": [
137-
"mdf.gini(df, 'x', negatives='shift')"
55+
"## Without weights"
13856
]
13957
},
14058
{
14159
"cell_type": "code",
142-
"execution_count": 7,
60+
"execution_count": null,
14361
"metadata": {},
144-
"outputs": [
145-
{
146-
"data": {
147-
"text/plain": [
148-
"0.6277777777777778"
149-
]
150-
},
151-
"execution_count": 7,
152-
"metadata": {},
153-
"output_type": "execute_result"
154-
}
155-
],
62+
"outputs": [],
15663
"source": [
157-
"mdf.gini(pd.DataFrame({'x': [0, 9, 10, 15, 110]}), 'x')"
64+
"# Create a MicroSeries without weights (equal weights)\n",
65+
"ms_unweighted = mdf.MicroSeries(df.x)\n",
66+
"print(f\"Unweighted Gini coefficient: {ms_unweighted.gini():.4f}\")"
15867
]
15968
},
16069
{
16170
"cell_type": "markdown",
16271
"metadata": {},
16372
"source": [
164-
"## Dealing with weights"
165-
]
166-
},
167-
{
168-
"cell_type": "code",
169-
"execution_count": 8,
170-
"metadata": {},
171-
"outputs": [
172-
{
173-
"data": {
174-
"text/plain": [
175-
"0.6800524934383202"
176-
]
177-
},
178-
"execution_count": 8,
179-
"metadata": {},
180-
"output_type": "execute_result"
181-
}
182-
],
183-
"source": [
184-
"mdf.gini(df, 'x', 'w')"
73+
"## Working with MicroDataFrame"
18574
]
18675
},
18776
{
18877
"cell_type": "code",
189-
"execution_count": 9,
78+
"execution_count": null,
19079
"metadata": {},
191-
"outputs": [
192-
{
193-
"data": {
194-
"text/plain": [
195-
"0.6800524934383202"
196-
]
197-
},
198-
"execution_count": 9,
199-
"metadata": {},
200-
"output_type": "execute_result"
201-
}
202-
],
80+
"outputs": [],
20381
"source": [
204-
"mdf.gini(pd.DataFrame({'x': [-10,\n",
205-
" -1, -1,\n",
206-
" 0, 0, 0,\n",
207-
" 5, 5, 5, 5,\n",
208-
" 100, 100, 100, 100, 100]}),\n",
209-
" 'x')"
82+
"# Create a MicroDataFrame\n",
83+
"mdf_df = mdf.MicroDataFrame(df, weights='w')\n",
84+
"\n",
85+
"# Access column as MicroSeries and calculate gini\n",
86+
"print(f\"Gini from MicroDataFrame column: {mdf_df.x.gini():.4f}\")"
21087
]
21188
}
21289
],
@@ -226,22 +103,9 @@
226103
"name": "python",
227104
"nbconvert_exporter": "python",
228105
"pygments_lexer": "ipython3",
229-
"version": "3.7.9"
230-
},
231-
"toc": {
232-
"base_numbering": 1,
233-
"nav_menu": {},
234-
"number_sections": true,
235-
"sideBar": true,
236-
"skip_h1_title": false,
237-
"title_cell": "Table of Contents",
238-
"title_sidebar": "Contents",
239-
"toc_cell": false,
240-
"toc_position": {},
241-
"toc_section_display": true,
242-
"toc_window_display": false
106+
"version": "3.7.7"
243107
}
244108
},
245109
"nbformat": 4,
246-
"nbformat_minor": 2
247-
}
110+
"nbformat_minor": 4
111+
}

microdf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
# microdataframe.py
1212
"MicroDataFrame",
1313
"MicroDataFrameGroupBy",
14-
]
14+
]

0 commit comments

Comments
 (0)