API Reference
This page is auto-generated from Python docstrings.
datafun
Datafun - data fundamentals course package.
app
src/datafun/app.py - Project script.
Author: Denise Case Date: 2026-08-20
HOW TO RUN THIS FILE:
From the VS Code menu (with only this project open in VS Code), click "Terminal" / New Terminal to open an integrated Terminal in the root project folder. Paste the following command and press ENTER or RETURN to run this file as a script:
uv run python -m datafun.app
DOMAIN:
A dataset of penguins. See docs/data-card.md for more information about the dataset.
EXPLORE:
Use Python to repeat and make decisions: - repeat work for each item in a list - branch based on a condition - transform values with a list comprehension - repeat work while a condition is true
ORGANIZATION:
This file is the main script for the project. Execution begins at the start of the main() function. We organize the instructions into different files (a Python file is called a module).
main
main() -> None
Entry point when running this file as a Python script.
This is where the instructions begin.
Arguments: None. Returns: None.
Source code in src/datafun/app.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
utils_data
src/datafun/data_utils.py - Utility functions for the project.
These functions do the reusable work:
- load a file,
- look at the data,
- describe it.
Each one receives everything it needs when the calling code "passes in" information via the parentheses (think of them as the only doorway into a function).
To reuse the function, just pass in different "arguments".
OBS: You should read, but should not need to modify this file.
RUN
No need. We don't usually run supporting modules like this one directly. This file exists to move messy repeatable instructions out of the main script.
get_analyst_description
get_analyst_description(
grain: str,
target: str,
feature: str,
why: str,
log: Logger,
) -> str
Get a formatted summary string of the analyst description.
These are the analyst's declarations, written after looking at the data. This is critical analyst work: look, then say what one row means, which of the columns might be a target we could predict, which of the columns might be a feature we could use if we were to build a model to predict the target, and why we think that feature might be related to the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grain
|
str
|
what one row means. |
required |
target
|
str
|
a thing we could try to predict. |
required |
feature
|
str
|
a feature (clue / indicator / column) that might help. |
required |
why
|
str
|
why this feature might help predict the target. |
required |
log
|
Logger
|
the logger to write progress to. |
required |
Returns:
| Type | Description |
|---|---|
str
|
a formatted multi-line string. |
Source code in src/datafun/utils_data.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
inspect
inspect(df: DataFrame, grain: str, log: Logger) -> str
Get a formatted inspection string from the data.
Ask the data about itself. No need to type column names by hand - the data knows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
the loaded pandas DataFrame (a 2-dimensional table like an Excel sheet). |
required |
grain
|
str
|
what one row represents. |
required |
log
|
Logger
|
the logger to send progress messages to. |
required |
Returns:
| Type | Description |
|---|---|
str
|
a formatted multi-line string. |
Source code in src/datafun/utils_data.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |