Skip to content

Commit e2156f6

Browse files
lpozoclaude
andcommitted
Resolve PROJECT_ROOT from the parent of the running folder
Positron starts a session in the folder holding the file, so Path.cwd() pointed at src/ or notebooks/ and the data path missed by one level. Use Path.cwd().parent in both scripts and the notebook, and document running them from their own folder. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent fac4670 commit e2156f6

4 files changed

Lines changed: 29 additions & 26 deletions

File tree

positron-ide/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ Select the project's `.venv` for both the Python Console and the notebook kernel
1414

1515
## Prepare and Analyze the Data
1616

17-
Run `src/prepare_sales.py` cell by cell in Positron, or run it from this folder:
17+
Run `src/prepare_sales.py` cell by cell in Positron, or run it from the `src/` folder:
1818

1919
```console
20-
uv run src/prepare_sales.py
20+
cd src
21+
uv run prepare_sales.py
2122
```
2223

24+
The scripts and the notebook build their paths with `PROJECT_ROOT = Path.cwd().parent`, so run them from the folder that holds them.
25+
2326
This creates `data/sales_clean.csv`. It checks for missing values, duplicates, and inconsistent totals, corrects a column name, parses dates, and normalizes category labels. It preserves all 5,130 source rows.
2427

2528
Next, run the cells in `src/analyze_sales.py` to inspect descriptive statistics, compare median order values between retail and wholesale orders, and view a Matplotlib chart. Use Positron's **Run Cell** controls to keep the resulting objects available in the Console and Variables pane.

positron-ide/notebooks/explore_sales.ipynb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "007a2246",
5+
"id": "4c1e042e",
66
"metadata": {},
77
"source": [
88
"# Explore Sales Orders\n",
@@ -12,18 +12,18 @@
1212
},
1313
{
1414
"cell_type": "markdown",
15-
"id": "e775e704",
15+
"id": "8ae0382c",
1616
"metadata": {},
1717
"source": [
1818
"## Load the Raw Data\n",
1919
"\n",
20-
"Import the project's libraries and read `data/sales_data.csv`. Open the project folder in Positron so the session starts at the project root."
20+
"Import the project's libraries and read `data/sales_data.csv`. The kernel starts in this `notebooks/` folder, so `PROJECT_ROOT` steps up one level to reach the project root."
2121
]
2222
},
2323
{
2424
"cell_type": "code",
2525
"execution_count": null,
26-
"id": "88383efa",
26+
"id": "25d214b8",
2727
"metadata": {},
2828
"outputs": [],
2929
"source": [
@@ -32,7 +32,7 @@
3232
"import matplotlib.pyplot as plt\n",
3333
"import pandas as pd\n",
3434
"\n",
35-
"PROJECT_ROOT = Path.cwd()\n",
35+
"PROJECT_ROOT = Path.cwd().parent\n",
3636
"\n",
3737
"sales = pd.read_csv(PROJECT_ROOT / \"data/sales_data.csv\")\n",
3838
"\n",
@@ -42,7 +42,7 @@
4242
},
4343
{
4444
"cell_type": "markdown",
45-
"id": "be568194",
45+
"id": "a470ad43",
4646
"metadata": {},
4747
"source": [
4848
"## Check Data Quality\n",
@@ -53,7 +53,7 @@
5353
{
5454
"cell_type": "code",
5555
"execution_count": null,
56-
"id": "374cce97",
56+
"id": "bb49f812",
5757
"metadata": {},
5858
"outputs": [],
5959
"source": [
@@ -68,7 +68,7 @@
6868
},
6969
{
7070
"cell_type": "markdown",
71-
"id": "bd02b9e0",
71+
"id": "efafe93e",
7272
"metadata": {},
7373
"source": [
7474
"## Inspect the Largest Orders\n",
@@ -79,7 +79,7 @@
7979
{
8080
"cell_type": "code",
8181
"execution_count": null,
82-
"id": "3cd51e0d",
82+
"id": "6fef73d5",
8383
"metadata": {},
8484
"outputs": [],
8585
"source": [
@@ -89,7 +89,7 @@
8989
},
9090
{
9191
"cell_type": "markdown",
92-
"id": "39d16a2d",
92+
"id": "2b3f369d",
9393
"metadata": {},
9494
"source": [
9595
"## Clean the Data\n",
@@ -100,7 +100,7 @@
100100
{
101101
"cell_type": "code",
102102
"execution_count": null,
103-
"id": "5de8943e",
103+
"id": "19acc30c",
104104
"metadata": {},
105105
"outputs": [],
106106
"source": [
@@ -115,7 +115,7 @@
115115
},
116116
{
117117
"cell_type": "markdown",
118-
"id": "68d59532",
118+
"id": "59e0cee4",
119119
"metadata": {},
120120
"source": [
121121
"## Verify the Totals\n",
@@ -126,7 +126,7 @@
126126
{
127127
"cell_type": "code",
128128
"execution_count": null,
129-
"id": "2d1feea1",
129+
"id": "5dd5fe37",
130130
"metadata": {},
131131
"outputs": [],
132132
"source": [
@@ -137,7 +137,7 @@
137137
},
138138
{
139139
"cell_type": "markdown",
140-
"id": "8af4e7c5",
140+
"id": "b245ddc1",
141141
"metadata": {},
142142
"source": [
143143
"## Describe the Data\n",
@@ -148,7 +148,7 @@
148148
{
149149
"cell_type": "code",
150150
"execution_count": null,
151-
"id": "a16889e4",
151+
"id": "41aa6fb0",
152152
"metadata": {},
153153
"outputs": [],
154154
"source": [
@@ -160,7 +160,7 @@
160160
},
161161
{
162162
"cell_type": "markdown",
163-
"id": "a9852e1d",
163+
"id": "891db419",
164164
"metadata": {},
165165
"source": [
166166
"## Compare Typical Orders\n",
@@ -171,7 +171,7 @@
171171
{
172172
"cell_type": "code",
173173
"execution_count": null,
174-
"id": "4ded6526",
174+
"id": "25aa795d",
175175
"metadata": {},
176176
"outputs": [],
177177
"source": [
@@ -188,7 +188,7 @@
188188
},
189189
{
190190
"cell_type": "markdown",
191-
"id": "7f8c2b68",
191+
"id": "1a5f5657",
192192
"metadata": {},
193193
"source": [
194194
"## Visualize the Comparison\n",
@@ -199,7 +199,7 @@
199199
{
200200
"cell_type": "code",
201201
"execution_count": null,
202-
"id": "1ac999fa",
202+
"id": "a604d65d",
203203
"metadata": {},
204204
"outputs": [],
205205
"source": [
@@ -217,7 +217,7 @@
217217
},
218218
{
219219
"cell_type": "markdown",
220-
"id": "b0fe3723",
220+
"id": "220350eb",
221221
"metadata": {},
222222
"source": [
223223
"## Add an Interactive Chart\n",
@@ -228,7 +228,7 @@
228228
{
229229
"cell_type": "code",
230230
"execution_count": null,
231-
"id": "2b6e2e6a",
231+
"id": "a856547e",
232232
"metadata": {},
233233
"outputs": [],
234234
"source": [
@@ -249,7 +249,7 @@
249249
},
250250
{
251251
"cell_type": "markdown",
252-
"id": "230e8d43",
252+
"id": "dc5e8033",
253253
"metadata": {},
254254
"source": [
255255
"## Optional Assistant Follow-Up\n",

positron-ide/src/analyze_sales.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import matplotlib.pyplot as plt
55
import pandas as pd
66

7-
PROJECT_ROOT = Path.cwd()
7+
PROJECT_ROOT = Path.cwd().parent
88

99
sales = pd.read_csv(
1010
PROJECT_ROOT / "data/sales_clean.csv",

positron-ide/src/prepare_sales.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pandas as pd
55

6-
PROJECT_ROOT = Path.cwd()
6+
PROJECT_ROOT = Path.cwd().parent
77

88
sales = pd.read_csv(PROJECT_ROOT / "data/sales_data.csv")
99

0 commit comments

Comments
 (0)