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:
The data is loaded from a CSV file in the data/ folder. Open that CSV in Excel and look at it. One row of data represents one penguin. We can - open Excel and explore data OR - open an editor and write Python
With Python, the instructions are write once / use as many times as we like, and we can copy the instructions to other projects. Work can be stored in GitHub and shared with others.
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
125 126 127 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 | |
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 | |