├── LICENSE ├── requirements.txt ├── .gitignore ├── FORTEACHERS.md ├── Introduction to pandas.ipynb ├── Python syntax cheat sheet.ipynb └── mlb-salaries-usa-today-2024.csv /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 IRE/NICAR 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | anyio==4.7.0 2 | appnope==0.1.4 3 | argon2-cffi==23.1.0 4 | argon2-cffi-bindings==21.2.0 5 | arrow==1.3.0 6 | asttokens==3.0.0 7 | async-lru==2.0.4 8 | attrs==24.3.0 9 | babel==2.16.0 10 | beautifulsoup4==4.12.3 11 | bleach==6.2.0 12 | certifi==2024.12.14 13 | cffi==1.17.1 14 | charset-normalizer==3.4.0 15 | comm==0.2.2 16 | debugpy==1.8.11 17 | decorator==5.1.1 18 | defusedxml==0.7.1 19 | executing==2.1.0 20 | fastjsonschema==2.21.1 21 | fqdn==1.5.1 22 | h11==0.14.0 23 | httpcore==1.0.7 24 | httpx==0.28.1 25 | idna==3.10 26 | ipykernel==6.29.5 27 | ipython==8.31.0 28 | isoduration==20.11.0 29 | jedi==0.19.2 30 | Jinja2==3.1.4 31 | json5==0.10.0 32 | jsonpointer==3.0.0 33 | jsonschema==4.23.0 34 | jsonschema-specifications==2024.10.1 35 | jupyter-events==0.11.0 36 | jupyter-lsp==2.2.5 37 | jupyter_client==8.6.3 38 | jupyter_core==5.7.2 39 | jupyter_server==2.15.0 40 | jupyter_server_terminals==0.5.3 41 | jupyterlab==4.3.4 42 | jupyterlab_pygments==0.3.0 43 | jupyterlab_server==2.27.3 44 | MarkupSafe==3.0.2 45 | matplotlib-inline==0.1.7 46 | mistune==3.0.2 47 | nbclient==0.10.2 48 | nbconvert==7.16.4 49 | nbformat==5.10.4 50 | nest-asyncio==1.6.0 51 | notebook_shim==0.2.4 52 | numpy==2.2.0 53 | overrides==7.7.0 54 | packaging==24.2 55 | pandas==2.2.3 56 | pandocfilters==1.5.1 57 | parso==0.8.4 58 | pexpect==4.9.0 59 | platformdirs==4.3.6 60 | prometheus_client==0.21.1 61 | prompt_toolkit==3.0.48 62 | psutil==6.1.1 63 | ptyprocess==0.7.0 64 | pure_eval==0.2.3 65 | pycparser==2.22 66 | Pygments==2.18.0 67 | python-dateutil==2.9.0.post0 68 | python-json-logger==3.2.1 69 | pytz==2024.2 70 | PyYAML==6.0.2 71 | pyzmq==26.2.0 72 | referencing==0.35.1 73 | requests==2.32.3 74 | rfc3339-validator==0.1.4 75 | rfc3986-validator==0.1.1 76 | rpds-py==0.22.3 77 | Send2Trash==1.8.3 78 | setuptools==75.6.0 79 | six==1.17.0 80 | sniffio==1.3.1 81 | soupsieve==2.6 82 | stack-data==0.6.3 83 | terminado==0.18.1 84 | tinycss2==1.4.0 85 | tornado==6.4.2 86 | traitlets==5.14.3 87 | types-python-dateutil==2.9.0.20241206 88 | tzdata==2024.2 89 | uri-template==1.3.0 90 | urllib3==2.2.3 91 | wcwidth==0.2.13 92 | webcolors==24.11.1 93 | webencodings==0.5.1 94 | websocket-client==1.8.0 95 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | # General 106 | .DS_Store 107 | .AppleDouble 108 | .LSOverride 109 | 110 | # Icon must end with two \r 111 | Icon 112 | 113 | 114 | # Thumbnails 115 | ._* 116 | 117 | # Files that might appear in the root of a volume 118 | .DocumentRevisions-V100 119 | .fseventsd 120 | .Spotlight-V100 121 | .TemporaryItems 122 | .Trashes 123 | .VolumeIcon.icns 124 | .com.apple.timemachine.donotpresent 125 | 126 | # Directories potentially created on remote AFP share 127 | .AppleDB 128 | .AppleDesktop 129 | Network Trash Folder 130 | Temporary Items 131 | .apdisk 132 | -------------------------------------------------------------------------------- /FORTEACHERS.md: -------------------------------------------------------------------------------- 1 | # IRE/NICAR conference teaching guide for "Python: Intro to data analysis using pandas" 2 | 3 | Thank you for volunteering to teach this one-hour session on using the `pandas` library to analyze data. This teaching guide explains our setup and the material to cover. 4 | 5 | The class is one hour long. The exercises live in [this Jupyter notebook](Introduction%20to%20pandas.ipynb). 6 | 7 | It would be a good idea to [take a spin through the notebook](#run-the-notebook) prior to teaching the session. 8 | 9 | ## Session description 10 | In this session, you'll learn how to analyze data using the popular Python data analysis library pandas. You'll learn about the benefits of scripting your data projects and enough syntax to load, sort, filter and group a data set. 11 | 12 | This class is good for: People who are comfortable working with data in spreadsheets or SQL and want to make the leap to programming. 13 | 14 | ## Session goals 15 | Attendees should leave with a basic understanding of: 16 | - How to write and run Python code in a Jupyter notebook 17 | - When it makes sense to script your analysis (as opposed to just using Excel, SQL, etc.) 18 | - Loading a CSV into a `pandas` dataframe 19 | - Inspecting the dataframe with `head()`, `describe()` and other methods 20 | - Sorting data with `sort_values()` 21 | - Filtering data 22 | - Grouping data (if time) 23 | - Where to find [instructions for installing Python on their own machines](https://docs.google.com/document/d/1cYmpfZEZ8r-09Q6Go917cKVcQk_d0P61gm0q8DAdIdg/edit#) 24 | - How to find help when they get stuck 25 | 26 | ## General approach 27 | I Do, We Do, You Do. Demonstrate a concept, go through it together, then give them plenty of time to experiment on their own while you and your coach walk around and answer questions (see sections marked `✍️ Try it yourself`). The pace will be slower than you think, and that's OK! It's not the end of the world if you don't get through everything. 28 | 29 | Most people who come to this class will have _zero_ experience with programming, so be empathetic and try to remember how frustrating it is to feel lost. 30 | 31 | Having the students open [the included syntax reference notebook](Python%20syntax%20cheat%20sheet.ipynb) can be useful for reinforcing Python basics. 32 | 33 | ## Class setup 34 | We'll have the latest version of Python 3 installed. We're using the standard library's `venv` module to manage the virtual environment and project dependencies (`jupyterlab` and `pandas`), which will already have been installed and tested prior to your session. Please refer to the Python setup sheet for the conference and let us know if you have any questions. 35 | 36 | ## Class outline 37 | 38 | ### Start up the notebook server 39 | Begin the class by (slowly!) walking everyone through the process of activating their virtual environments and launching Jupyter: 40 | 1. Open Terminal (or `cmd` or `Cygwin` if you're on a PC) 41 | 2. `cd` into your class directory 42 | 3. Activate the virtual environment: 43 | - Macs: `source env/bin/activate` 44 | - PCs: `.\env\Scripts\activate` 45 | 4. `jupyter lab` 46 | 47 | It will take everyone a few minutes to get going. You'll also probably get some questions about what, exactly, you're doing at this step. Try to avoid a lengthy digression into virtual environments -- it's beyond the scope of this hourlong session, so maybe offer to talk to them after class, or send 'em our way: [training@ire.org](mailto:training@ire.org). 48 | 49 | Once everyone is good to go, toggle back to the terminal and show them what's going on: A Jupyter server is running in the background, so don't close that terminal window! 50 | 51 | Go over some notebook basics: Adding cells, writing code and running cells, etc. A common beginner gotcha: Writing code that other cells depend on but forgetting to first _run_ it to make it available. 52 | 53 | ### Main course content 54 | Start marching down the notebook: Importing pandas, loading data from file, sorting, filtering, grouping. Pause frequently to ask if anyone has questions. 55 | 56 | Any time you see `✍️ Try it yourself`, hit the brakes and give everyone time to play around with whatever concept you're discussing. 57 | 58 | ### Debugging 59 | If you can, find an opportunity when someone has gotten an error and take 5 minutes to walk through basic debugging strategy: Reading the traceback error from bottom to top, strategic Googling, etc. 60 | 61 | ### If you have extra time at the end 62 | Unlikely! But if you have extra time, oversee some unstructured lab time -- they can practice syntax or look up additional methods, find their own data to work with, etc. 63 | 64 | ### Ending the session 65 | 1. Have everyone close out of their notebook tabs 66 | 2. In terminal, `Ctrl+C` to kill the server process 67 | 3. Close the terminal window 68 | 69 | ## Run the notebook 70 | 71 | You'll need Python 3 installed on your computer. [Here's our install guide](https://docs.google.com/document/d/1cYmpfZEZ8r-09Q6Go917cKVcQk_d0P61gm0q8DAdIdg/edit?usp=sharing). 72 | 73 | 1. Clone or [download/unzip](https://github.com/ireapps/teaching-guide-intro-to-pandas/archive/master.zip) this repo onto your computer 74 | 2. In your command-line interface, `cd` into the folder 75 | 3. Create a virtual environment: 76 | - Macs: `python3 -m venv env` 77 | - PCs: `python -m venv env` 78 | 4. Activate the virtual environment: 79 | - Macs: `source env/bin/activate` 80 | - PCs: `.\env\Scripts\activate` 81 | 5. `pip install -r requirements.txt` 82 | 6. `jupyter lab` 83 | -------------------------------------------------------------------------------- /Introduction to pandas.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Introduction to pandas\n", 8 | "\n", 9 | "This notebook will introduce you to the [`pandas`](https://pandas.pydata.org/) data analysis library and demonstrate how to inspect, sort, filter, group and aggregate a data set.\n", 10 | "\n", 11 | "The data for this exercise will be a CSV of [USA TODAY's opening-day MLB salaries](https://www.usatoday.com/sports/mlb/salaries/).\n", 12 | "\n", 13 | "If you're completely new to Python or your syntax is rusty, it might be useful to [keep this notebook open in a new tab](Python%20syntax%20cheat%20sheet.ipynb) as a reference.\n", 14 | "\n", 15 | "#### Ssession outline\n", 16 | "- [Using Jupyter notebooks](#Using-Jupyter-notebooks)\n", 17 | "- [Import pandas](#Import-pandas)\n", 18 | "- [Load data into a data frame](#Load-data-into-a-data-frame)\n", 19 | "- [Inspect the data](#Inspect-the-data)\n", 20 | "- [Sort the data](#Sort-the-data)\n", 21 | "- [Filter the data](#Filter-the-data)\n", 22 | "- [Group and aggregate the data](#Group-and-aggregate-the-data)\n", 23 | "- [Export to CSV](#Export-to-CSV)" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "### Using Jupyter notebooks\n", 31 | "\n", 32 | "There are many ways to write and run Python code on your computer. One way -- the method we're using today -- is to use [Jupyter notebooks](https://jupyter.org/), which run in your browser and allow you to intersperse documentation with your code. They're handy for bundling your code with a human-readable explanation of what's happening at each step. Check out some examples from the [L.A. Times](https://github.com/datadesk/notebooks) and [BuzzFeed News](https://github.com/BuzzFeedNews/everything#data-and-analyses).\n", 33 | "\n", 34 | "**To add a new cell to your notebook**: Click the + button in the menu.\n", 35 | "\n", 36 | "**To run a cell of code**: Select the cell and click the \"Run\" button in the menu, or you can press Shift+Enter.\n", 37 | "\n", 38 | "**One common gotcha**: The notebook doesn't \"know\" about code you've written until you've _run_ the cell containing it. For example, if you define a variable called `my_name` in one cell, and later, when you try to access that variable in another cell but get an error that says `NameError: name 'my_name' is not defined`, the most likely solution is to run (or re-run) the cell in which you defined `my_name`." 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": {}, 44 | "source": [ 45 | "### Import pandas\n", 46 | "\n", 47 | "Before you can use the functionality of `pandas`, a third-party library installed separately from Python, you need to _import_ it. The convention is to import the library under an alias that's easier to type: `as pd`.\n", 48 | "\n", 49 | "Run this cell:" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": { 56 | "scrolled": true 57 | }, 58 | "outputs": [], 59 | "source": [ 60 | "import pandas as pd" 61 | ] 62 | }, 63 | { 64 | "cell_type": "markdown", 65 | "metadata": {}, 66 | "source": [ 67 | "### Change a display setting\n", 68 | "\n", 69 | "Run the next cell to change a setting that displays big numbers in scientific notation by default. (Unless scientific notation is your jam, in which case _avoid_ running the next cell.)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": null, 75 | "metadata": { 76 | "scrolled": true 77 | }, 78 | "outputs": [], 79 | "source": [ 80 | "# https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html\n", 81 | "pd.options.display.float_format = '{:20,.2f}'.format" 82 | ] 83 | }, 84 | { 85 | "cell_type": "markdown", 86 | "metadata": {}, 87 | "source": [ 88 | "### Load data into a data frame\n", 89 | "\n", 90 | "Before you can start poking at a data file, you need to load the data into a pandas _data frame_, which is sort of like a virtual spreadsheet with columns and rows.\n", 91 | "\n", 92 | "You can load many different types of data files into a data frame, including CSVs (and other delimited text files), Excel files, JSON [and more](https://www.cbtnuggets.com/blog/2018/10/14-file-types-you-can-import-into-pandas/). ([Here's a notebook](https://github.com/ireapps/cfj-2018/blob/master/reference/Importing%20data%20into%20pandas.ipynb) demonstrating how to import some different data files, including live data from the Internet!)\n", 93 | "\n", 94 | "For today, we'll focus on importing the MLB salary data using a pandas method called [`read_csv()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html). There are a ton of options you can supply when you read in the data file, but at minimum, you need to tell the method _where_ the file lives, which means you need to supply the path to the data file as a Python _string_ (some text enclosed in single or double quotes). The file is called `mlb-salaries-2023.csv`, and it is located in the same directory as this notebook file, so we don't need to specify a longer path.\n", 95 | "\n", 96 | "As we import the data, we'll also _assign_ the results of the loading operation to a new variable we have decided to call _df_ (short for data frame -- easy to type, plus you'll see this pattern a lot when Googling around for help).\n", 97 | "\n", 98 | "👉 [Click here for more information on Python variables](Python%20syntax%20cheat%20sheet.ipynb#Variable-assignment)." 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": null, 104 | "metadata": { 105 | "scrolled": true 106 | }, 107 | "outputs": [], 108 | "source": [ 109 | "df = pd.read_csv('mlb-salaries-usa-today-2024.csv')" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "As a human sentence: \"Go to the pandas library that we imported earlier as something called `pd` and use its `read_csv()` method to import a file called `mlb-salaries-usa-today-2024.csv` into a data frame -- and assign the results of that operation to a new variable called `df`.\"" 117 | ] 118 | }, 119 | { 120 | "cell_type": "markdown", 121 | "metadata": {}, 122 | "source": [ 123 | "### Inspect the data\n", 124 | "\n", 125 | "Let's take a look at what we've got using a few built-in methods and attributes of a pandas data frame:\n", 126 | "- `df.head()` will display the first five records (or, if you prefer, you can specify a number, e.g., `df.head(10)`)\n", 127 | "- `df.tail()` will display the last five records (or, if you prefer, you can specify a number, e.g., `df.tail(10)`)\n", 128 | "- `df.describe()` will compute summary stats on numeric columns\n", 129 | "- `df.sample()` will return a randomly selected record (or, if you prefer, you specify a number, e.g., `df.sample(5)`\n", 130 | "- `df.shape` will tell you how many columns, how many rows\n", 131 | "- Using the Python function `len()` is another way to get a record count: `len(df)`\n", 132 | "- `df.dtypes` will list the column names and tell you what kind of data is in each one" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": null, 138 | "metadata": { 139 | "scrolled": true 140 | }, 141 | "outputs": [], 142 | "source": [ 143 | "df.head()" 144 | ] 145 | }, 146 | { 147 | "cell_type": "code", 148 | "execution_count": null, 149 | "metadata": { 150 | "scrolled": true 151 | }, 152 | "outputs": [], 153 | "source": [] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": { 159 | "scrolled": true 160 | }, 161 | "outputs": [], 162 | "source": [] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": null, 167 | "metadata": { 168 | "scrolled": true 169 | }, 170 | "outputs": [], 171 | "source": [] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": null, 176 | "metadata": { 177 | "scrolled": true 178 | }, 179 | "outputs": [], 180 | "source": [] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "### Sort the data\n", 187 | "\n", 188 | "To sort a data frame, use the `sort_values()` method. At a minimum, you need to tell it which column to sort on." 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "metadata": { 195 | "scrolled": true 196 | }, 197 | "outputs": [], 198 | "source": [ 199 | "df.sort_values('salary')" 200 | ] 201 | }, 202 | { 203 | "cell_type": "markdown", 204 | "metadata": {}, 205 | "source": [ 206 | "To sort descending, you need to pass in another argument to the `sort_values()` method: `ascending=False`. Note that the boolean value is _not_ a string, so it's not contained in quotes, and only the initial letter is capitalized. (If you are supplying multiple arguments to a function or method, separate them with commas.)\n", 207 | "\n", 208 | "👉 [Click here for more information on Python booleans](Python%20syntax%20cheat%20sheet.ipynb#Booleans)." 209 | ] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": null, 214 | "metadata": { 215 | "scrolled": true 216 | }, 217 | "outputs": [], 218 | "source": [ 219 | "df.sort_values('salary', ascending=False)" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": {}, 225 | "source": [ 226 | "You can use a process called \"method chaining\" to perform multiple operations in one line. If, for instance, we wanted to sort the data frame by salary descending and inspect the first 5 records returned:" 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": null, 232 | "metadata": { 233 | "scrolled": true 234 | }, 235 | "outputs": [], 236 | "source": [ 237 | "df.sort_values('salary', ascending=False).head()" 238 | ] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "metadata": {}, 243 | "source": [ 244 | "You can sort by multiple columns by passing in a _list_ of column names rather than the name of a single column. A list is a collection of items enclosed within square brackets `[]`.\n", 245 | "\n", 246 | "👉 [Click here for more information on Python lists](Python%20syntax%20cheat%20sheet.ipynb#Lists).\n", 247 | "\n", 248 | "To sort first by `salary`, then by `team`:" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": null, 254 | "metadata": { 255 | "scrolled": true 256 | }, 257 | "outputs": [], 258 | "source": [ 259 | "df.sort_values(['salary', 'team']).head()" 260 | ] 261 | }, 262 | { 263 | "cell_type": "markdown", 264 | "metadata": {}, 265 | "source": [ 266 | "You can specify the sort order (descending vs. ascending) for each sort column by passing another list to the `ascending` keyword with `True` and `False` items corresponding to the position of the columns in the first list. \n", 267 | "\n", 268 | "For example, to sort by `salary` descending, then by `team` ascending:" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": { 275 | "scrolled": true 276 | }, 277 | "outputs": [], 278 | "source": [ 279 | "df.sort_values(['salary', 'team'], ascending=[False, True]).head()" 280 | ] 281 | }, 282 | { 283 | "cell_type": "markdown", 284 | "metadata": {}, 285 | "source": [ 286 | "The `False` goes with `salary` and the `True` with `team` because they're in the same position in their respective lists." 287 | ] 288 | }, 289 | { 290 | "cell_type": "markdown", 291 | "metadata": {}, 292 | "source": [ 293 | "One other note: Despite all of this sorting we've been doing, the original `df` data frame is unchanged:" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": null, 299 | "metadata": { 300 | "scrolled": true 301 | }, 302 | "outputs": [], 303 | "source": [ 304 | "df.head()" 305 | ] 306 | }, 307 | { 308 | "cell_type": "markdown", 309 | "metadata": {}, 310 | "source": [ 311 | "That's because we haven't \"saved\" the results of those sorts by assigning them to a new variable. Typically, if you want to preserve a sort (or any other kind of manipulation), you'd would assign the results to a new variable:" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": null, 317 | "metadata": { 318 | "scrolled": true 319 | }, 320 | "outputs": [], 321 | "source": [ 322 | "sorted_by_team = df.sort_values('team')" 323 | ] 324 | }, 325 | { 326 | "cell_type": "code", 327 | "execution_count": null, 328 | "metadata": { 329 | "scrolled": true 330 | }, 331 | "outputs": [], 332 | "source": [ 333 | "sorted_by_team.head()" 334 | ] 335 | }, 336 | { 337 | "cell_type": "markdown", 338 | "metadata": {}, 339 | "source": [ 340 | "### ✍️ Your turn\n", 341 | "\n", 342 | "In the cells below, practice sorting the `df` data frame:\n", 343 | "- By `name`\n", 344 | "- By `position` descending\n", 345 | "- By `salary` descending, then by `position` ascending, and save the results to a new variable called `sorted_by_salary_then_position`" 346 | ] 347 | }, 348 | { 349 | "cell_type": "code", 350 | "execution_count": null, 351 | "metadata": { 352 | "scrolled": true 353 | }, 354 | "outputs": [], 355 | "source": [] 356 | }, 357 | { 358 | "cell_type": "code", 359 | "execution_count": null, 360 | "metadata": { 361 | "scrolled": true 362 | }, 363 | "outputs": [], 364 | "source": [] 365 | }, 366 | { 367 | "cell_type": "code", 368 | "execution_count": null, 369 | "metadata": { 370 | "scrolled": true 371 | }, 372 | "outputs": [], 373 | "source": [] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": null, 378 | "metadata": { 379 | "scrolled": true 380 | }, 381 | "outputs": [], 382 | "source": [] 383 | }, 384 | { 385 | "cell_type": "code", 386 | "execution_count": null, 387 | "metadata": { 388 | "scrolled": true 389 | }, 390 | "outputs": [], 391 | "source": [] 392 | }, 393 | { 394 | "cell_type": "markdown", 395 | "metadata": {}, 396 | "source": [ 397 | "### Filter the data\n", 398 | "\n", 399 | "Let's go over two different kinds of filtering:\n", 400 | "\n", 401 | "- Column filtering: Grabbing one or more columns of data to look at, like passing column names to a `SELECT` statement in SQL.\n", 402 | "- Row filtering: Looking at a subset of your data that matches some criteria, like the crieria following a `WHERE` statement in SQL. (For instance, \"Show me all records in my data frame where the value in the `team` column is \"Arizona\".)" 403 | ] 404 | }, 405 | { 406 | "cell_type": "markdown", 407 | "metadata": {}, 408 | "source": [ 409 | "#### Column filtering\n", 410 | "\n", 411 | "To access the values in a single column of data, you can use \"dot notation\" as long as the column name doesn't have spaces or other special characters:" 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "execution_count": null, 417 | "metadata": { 418 | "scrolled": true 419 | }, 420 | "outputs": [], 421 | "source": [ 422 | "df.team" 423 | ] 424 | }, 425 | { 426 | "cell_type": "markdown", 427 | "metadata": {}, 428 | "source": [ 429 | "Otherwise, use \"bracket notation\" with the name of the column as a string.\n", 430 | "\n", 431 | "This is equivalent to the previous command:" 432 | ] 433 | }, 434 | { 435 | "cell_type": "code", 436 | "execution_count": null, 437 | "metadata": { 438 | "scrolled": true 439 | }, 440 | "outputs": [], 441 | "source": [ 442 | "df['team']" 443 | ] 444 | }, 445 | { 446 | "cell_type": "markdown", 447 | "metadata": {}, 448 | "source": [ 449 | "When you access a single column in your data frame, you're getting back something called a [`Series`](https://pandas.pydata.org/docs/reference/api/pandas.Series.html) object (as opposed to a `DataFrame` object).\n", 450 | "\n", 451 | "One of the methods you can call on a Series is `unique()`, which shows you each unique value in the column. Let's do that with the `team` column:" 452 | ] 453 | }, 454 | { 455 | "cell_type": "code", 456 | "execution_count": null, 457 | "metadata": { 458 | "scrolled": true 459 | }, 460 | "outputs": [], 461 | "source": [ 462 | "df['team'].unique()" 463 | ] 464 | }, 465 | { 466 | "cell_type": "markdown", 467 | "metadata": {}, 468 | "source": [ 469 | "What we just did is the equivalent of dragging the \"team\" column name into the \"rows\" area of a spreadsheet pivot table, or, in SQL,\n", 470 | "\n", 471 | "```sql\n", 472 | "SELECT DISTINCT TEAM\n", 473 | "FROM mlb\n", 474 | "```\n", 475 | "\n", 476 | "You can also count up a total for each value using the `value_counts()` method:" 477 | ] 478 | }, 479 | { 480 | "cell_type": "code", 481 | "execution_count": null, 482 | "metadata": { 483 | "scrolled": true 484 | }, 485 | "outputs": [], 486 | "source": [ 487 | "df['team'].value_counts()" 488 | ] 489 | }, 490 | { 491 | "cell_type": "markdown", 492 | "metadata": {}, 493 | "source": [ 494 | "For numeric columns, you can call methods on that Series to compute basic summary stats:\n", 495 | "- `min()` to get the lowest value\n", 496 | "- `max()` to get the greatest value\n", 497 | "- `median()` to get the median\n", 498 | "- `mean()` to get the average\n", 499 | "- `mode()` to get the most common value\n", 500 | "\n", 501 | "Check it out for the `SALARY` column:" 502 | ] 503 | }, 504 | { 505 | "cell_type": "code", 506 | "execution_count": null, 507 | "metadata": { 508 | "scrolled": true 509 | }, 510 | "outputs": [], 511 | "source": [ 512 | "df['salary'].min()" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": null, 518 | "metadata": { 519 | "scrolled": true 520 | }, 521 | "outputs": [], 522 | "source": [ 523 | "df['salary'].max()" 524 | ] 525 | }, 526 | { 527 | "cell_type": "code", 528 | "execution_count": null, 529 | "metadata": { 530 | "scrolled": true 531 | }, 532 | "outputs": [], 533 | "source": [ 534 | "df['salary'].median()" 535 | ] 536 | }, 537 | { 538 | "cell_type": "code", 539 | "execution_count": null, 540 | "metadata": { 541 | "scrolled": true 542 | }, 543 | "outputs": [], 544 | "source": [ 545 | "df['salary'].mean()" 546 | ] 547 | }, 548 | { 549 | "cell_type": "code", 550 | "execution_count": null, 551 | "metadata": { 552 | "scrolled": true 553 | }, 554 | "outputs": [], 555 | "source": [ 556 | "df['salary'].mode()" 557 | ] 558 | }, 559 | { 560 | "cell_type": "markdown", 561 | "metadata": {}, 562 | "source": [ 563 | "To select multiple columns in your data frame, use bracket notation but pass in a _list_ of column names instead of just one. To make things clearer, you could break this out into two steps:" 564 | ] 565 | }, 566 | { 567 | "cell_type": "code", 568 | "execution_count": null, 569 | "metadata": { 570 | "scrolled": true 571 | }, 572 | "outputs": [], 573 | "source": [ 574 | "columns_we_care_about = ['team', 'salary']\n", 575 | "df[columns_we_care_about]" 576 | ] 577 | }, 578 | { 579 | "cell_type": "markdown", 580 | "metadata": {}, 581 | "source": [ 582 | "#### Row filtering\n", 583 | "\n", 584 | "To make things maximally confusing, you _also_ use bracket notation for row filtering. Except in this case, instead of dropping the name of a column (or a list of column names) into the brackets, you hand it a _logical condition_ that resolves to `True` or `False`.\n", 585 | "\n", 586 | "Let's filter our data to see players who make more than $1 million (in other words, return rows of data where the value in the `salary` column is greater than 1000000):\n", 587 | "\n", 588 | "(The equivalent SQL statement would be:\n", 589 | "```sql\n", 590 | "SELECT *\n", 591 | "FROM mlb\n", 592 | "WHERE SALARY > 1000000\n", 593 | "```\n", 594 | ")" 595 | ] 596 | }, 597 | { 598 | "cell_type": "code", 599 | "execution_count": null, 600 | "metadata": { 601 | "scrolled": true 602 | }, 603 | "outputs": [], 604 | "source": [ 605 | "df[df['salary'] > 1000000]" 606 | ] 607 | }, 608 | { 609 | "cell_type": "markdown", 610 | "metadata": {}, 611 | "source": [ 612 | "For many filters, you'll use Python's comparison operators:\n", 613 | "- `>` greater than\n", 614 | "- `>=` greater than or equal to\n", 615 | "- `<` less than\n", 616 | "- `<=` less than or equal to\n", 617 | "- `==` equal to\n", 618 | "- `!=` not equal to\n", 619 | "\n", 620 | "#### Multiple filter conditions\n", 621 | "\n", 622 | "What if you want to use multiple filtering conditions? There is a way, but it usually makes more sense -- and is much easier for your colleagues and your future self to think about and debug -- to _save_ the results of each filtering operation by assigning the results to a new variable, then filter _the filtered data frame_ again instead of the original data frame.\n", 623 | "\n", 624 | "For example, if you wanted to look at Colorado Rockies players who make more than $1 million, you might do something like:" 625 | ] 626 | }, 627 | { 628 | "cell_type": "code", 629 | "execution_count": null, 630 | "metadata": { 631 | "scrolled": true 632 | }, 633 | "outputs": [], 634 | "source": [ 635 | "rockies = df[df['team'] == 'Rockies']\n", 636 | "rockies_over_1m = rockies[rockies['salary'] > 1000000]" 637 | ] 638 | }, 639 | { 640 | "cell_type": "code", 641 | "execution_count": null, 642 | "metadata": { 643 | "scrolled": true 644 | }, 645 | "outputs": [], 646 | "source": [ 647 | "rockies_over_1m" 648 | ] 649 | }, 650 | { 651 | "cell_type": "markdown", 652 | "metadata": {}, 653 | "source": [ 654 | "👉 [Check out some other filtering operations here]()." 655 | ] 656 | }, 657 | { 658 | "cell_type": "markdown", 659 | "metadata": {}, 660 | "source": [ 661 | "### ✍️ Your turn\n", 662 | "\n", 663 | "In the cells below, practice filtering:\n", 664 | "- Column filtering: Select the `name` column\n", 665 | "- Column filtering: Select the `name` and `team` columns\n", 666 | "- Row filtering: Filter the rows to return only players who make the league minimum (by definition, the lowest number in the `salary` column)\n", 667 | "- Row filtering: Filter the rows to return only catchers (`C`) who make at least $750,000\n", 668 | "- BONUS: Filter the rows to return only players for the Chicago White Sox, then use method chaining to order the results by `salary` descending" 669 | ] 670 | }, 671 | { 672 | "cell_type": "code", 673 | "execution_count": null, 674 | "metadata": { 675 | "scrolled": true 676 | }, 677 | "outputs": [], 678 | "source": [] 679 | }, 680 | { 681 | "cell_type": "code", 682 | "execution_count": null, 683 | "metadata": { 684 | "scrolled": true 685 | }, 686 | "outputs": [], 687 | "source": [] 688 | }, 689 | { 690 | "cell_type": "code", 691 | "execution_count": null, 692 | "metadata": { 693 | "scrolled": true 694 | }, 695 | "outputs": [], 696 | "source": [] 697 | }, 698 | { 699 | "cell_type": "code", 700 | "execution_count": null, 701 | "metadata": { 702 | "scrolled": true 703 | }, 704 | "outputs": [], 705 | "source": [] 706 | }, 707 | { 708 | "cell_type": "code", 709 | "execution_count": null, 710 | "metadata": { 711 | "scrolled": true 712 | }, 713 | "outputs": [], 714 | "source": [] 715 | }, 716 | { 717 | "cell_type": "markdown", 718 | "metadata": {}, 719 | "source": [ 720 | "### Group and aggregate the data\n", 721 | "\n", 722 | "Data frames have a `groupby` method for grouping and aggregating data, similar to what you might do in a pivot table or a `GROUP BY` statement in SQL. (They also have a [`pivot_table` method](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.pivot_table.html), which can be homework for you to research.)\n", 723 | "\n", 724 | "Let's say we wanted to see the top 10 teams by payroll. In other words, we want to:\n", 725 | "- Group the data by the `team` column: `groupby()`\n", 726 | "- Add up the records in each group: `sum()`\n", 727 | "- Sort the results by `salary` descending: `sort_values()`\n", 728 | "- Take only the top 10 results: `head(10)`\n", 729 | "\n", 730 | "Calling the `groupby()` method without telling it what to do with the grouped records isn't super helpful:" 731 | ] 732 | }, 733 | { 734 | "cell_type": "code", 735 | "execution_count": null, 736 | "metadata": { 737 | "scrolled": true 738 | }, 739 | "outputs": [], 740 | "source": [ 741 | "df.groupby('team')" 742 | ] 743 | }, 744 | { 745 | "cell_type": "markdown", 746 | "metadata": {}, 747 | "source": [ 748 | "At this point, it's basically telling us that it has successfully grouped the records -- now what? Using method chaining, describe what you would like to _do_ with the numeric columns once you've grouped the data. Let's start with `sum()`:" 749 | ] 750 | }, 751 | { 752 | "cell_type": "code", 753 | "execution_count": null, 754 | "metadata": { 755 | "scrolled": true 756 | }, 757 | "outputs": [], 758 | "source": [ 759 | "df.groupby('team').sum()" 760 | ] 761 | }, 762 | { 763 | "cell_type": "markdown", 764 | "metadata": {}, 765 | "source": [ 766 | "Ope! It's summing _every_ column, not just `salary`.\n", 767 | "\n", 768 | "To deal with this, use column filtering to select the two columns we're interested in -- `team` for grouping and `salary` for summing -- and _then_ tack on the `groupby` statement, etc.\n", 769 | "\n", 770 | "(Remember: To select columns from a data frame, use bracket notation and hand it a _list_ of column names.)" 771 | ] 772 | }, 773 | { 774 | "cell_type": "code", 775 | "execution_count": null, 776 | "metadata": { 777 | "scrolled": true 778 | }, 779 | "outputs": [], 780 | "source": [ 781 | "df[['team', 'salary']].groupby('team').sum()" 782 | ] 783 | }, 784 | { 785 | "cell_type": "markdown", 786 | "metadata": {}, 787 | "source": [ 788 | "Bang bang. Now, using method chaining, let's sort by `salary` descending and look at just the top 10:" 789 | ] 790 | }, 791 | { 792 | "cell_type": "code", 793 | "execution_count": null, 794 | "metadata": { 795 | "scrolled": true 796 | }, 797 | "outputs": [], 798 | "source": [ 799 | "df[['team', 'salary']].groupby('team').sum().sort_values('salary', ascending=False).head(10)" 800 | ] 801 | }, 802 | { 803 | "cell_type": "markdown", 804 | "metadata": {}, 805 | "source": [ 806 | "You can use aggregation methods other than `sum()` -- `mean()` and `median()`, for instance -- or you can use [the `agg()` method](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.agg.html) to specify one or more aggregation methods to apply." 807 | ] 808 | }, 809 | { 810 | "cell_type": "code", 811 | "execution_count": null, 812 | "metadata": { 813 | "scrolled": true 814 | }, 815 | "outputs": [], 816 | "source": [ 817 | "df[['team', 'salary']].groupby('team').median()" 818 | ] 819 | }, 820 | { 821 | "cell_type": "code", 822 | "execution_count": null, 823 | "metadata": { 824 | "scrolled": true 825 | }, 826 | "outputs": [], 827 | "source": [ 828 | "df[['team', 'salary']].groupby('team').mean()" 829 | ] 830 | }, 831 | { 832 | "cell_type": "code", 833 | "execution_count": null, 834 | "metadata": { 835 | "scrolled": true 836 | }, 837 | "outputs": [], 838 | "source": [ 839 | "df[['team', 'salary']].groupby('team').agg(['sum', 'mean', 'median'])" 840 | ] 841 | }, 842 | { 843 | "cell_type": "markdown", 844 | "metadata": {}, 845 | "source": [ 846 | "### ✍️ Your turn\n", 847 | "\n", 848 | "In the cells below, practice grouping data:\n", 849 | "- What's the median salary for each position? Group the data by `position` and aggregate by `median()`, then sort by `salary` descending\n", 850 | "- What's the average salary on each team? Group the data by `team` and aggregate by `sum()`, then sort by `salary` descending\n", 851 | "- What else?" 852 | ] 853 | }, 854 | { 855 | "cell_type": "code", 856 | "execution_count": null, 857 | "metadata": { 858 | "scrolled": true 859 | }, 860 | "outputs": [], 861 | "source": [] 862 | }, 863 | { 864 | "cell_type": "code", 865 | "execution_count": null, 866 | "metadata": { 867 | "scrolled": true 868 | }, 869 | "outputs": [], 870 | "source": [] 871 | }, 872 | { 873 | "cell_type": "code", 874 | "execution_count": null, 875 | "metadata": { 876 | "scrolled": true 877 | }, 878 | "outputs": [], 879 | "source": [] 880 | }, 881 | { 882 | "cell_type": "code", 883 | "execution_count": null, 884 | "metadata": { 885 | "scrolled": true 886 | }, 887 | "outputs": [], 888 | "source": [] 889 | }, 890 | { 891 | "cell_type": "markdown", 892 | "metadata": {}, 893 | "source": [ 894 | "### Export to CSV\n", 895 | "\n", 896 | "To export a dataframe to a delimited text file, use the [`to_csv()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html) method. If you don't want to include the index numbers, specify `index=False`." 897 | ] 898 | }, 899 | { 900 | "cell_type": "code", 901 | "execution_count": null, 902 | "metadata": { 903 | "scrolled": true 904 | }, 905 | "outputs": [], 906 | "source": [ 907 | "df.to_csv('my-cool-data-frame.csv', index=False)" 908 | ] 909 | } 910 | ], 911 | "metadata": { 912 | "kernelspec": { 913 | "display_name": "Python 3 (ipykernel)", 914 | "language": "python", 915 | "name": "python3" 916 | }, 917 | "language_info": { 918 | "codemirror_mode": { 919 | "name": "ipython", 920 | "version": 3 921 | }, 922 | "file_extension": ".py", 923 | "mimetype": "text/x-python", 924 | "name": "python", 925 | "nbconvert_exporter": "python", 926 | "pygments_lexer": "ipython3", 927 | "version": "3.13.2" 928 | } 929 | }, 930 | "nbformat": 4, 931 | "nbformat_minor": 4 932 | } 933 | -------------------------------------------------------------------------------- /Python syntax cheat sheet.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python syntax cheat sheet\n", 8 | "\n", 9 | "This notebook demonstrates some basic syntax rules of the Python programming language.\n", 10 | "\n", 11 | "- [Basic data types](#Basic-data-types)\n", 12 | " - [Strings](#Strings)\n", 13 | " - [Numbers and math](#Numbers-and-math)\n", 14 | " - [Booleans](#Booleans)\n", 15 | "- [Variable assignment](#Variable-assignment)\n", 16 | "- [String methods](#String-methods)\n", 17 | "- [Comments](#Comments)\n", 18 | "- [The print() function](#The-print()-function)\n", 19 | "- [Collections of data](#Collections-of-data)\n", 20 | " - [Lists](#Lists)\n", 21 | " - [Dictionaries](#Dictionaries)\n", 22 | "- [`for` loops](#for-loops)\n", 23 | "- [`if` statements](#if-statements)" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": {}, 29 | "source": [ 30 | "### Basic data types\n", 31 | "Just like Excel and other data processing software, Python recognizes a variety of data types, including three we'll focus on here:\n", 32 | "- Strings (text)\n", 33 | "- Numbers (integers, numbers with decimals and more)\n", 34 | "- Booleans (`True` and `False`).\n", 35 | "\n", 36 | "You can use the built-in [`type()`](https://docs.python.org/3/library/functions.html#type) function to check the data type of a value." 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "#### Strings\n", 44 | "\n", 45 | "A string is a group of characters -- letters, numbers, whatever -- enclosed within single or double quotes (doesn't matter as long as they match). The code in these notebooks uses single quotes. (The Python style guide doesn't recommend one over the other: [\"Pick a rule and stick to it.\"](https://www.python.org/dev/peps/pep-0008/#string-quotes))\n", 46 | "\n", 47 | "If your string _contains_ apostrophes or quotes, you have two options: _Escape_ the offending character with a forward slash `\\`:\n", 48 | "\n", 49 | "```python\n", 50 | "'Isn\\'t it nice here?'\n", 51 | "```\n", 52 | "\n", 53 | "... or change the surrounding punctuation:\n", 54 | "\n", 55 | "```python\n", 56 | "\"Isn't it nice here?\"\n", 57 | "```\n", 58 | "\n", 59 | "The style guide recommends the latter over the former.\n", 60 | "\n", 61 | "When you call the `type()` function on a string, Python will return `str`.\n", 62 | "\n", 63 | "Calling the [`str()` function](https://docs.python.org/3/library/stdtypes.html#str) on a value will return the string version of that value (see examples below)." 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "'Investigative Reporters and Editors'" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": null, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "type('hello!')" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": null, 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "45" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": null, 96 | "metadata": {}, 97 | "outputs": [], 98 | "source": [ 99 | "type(45)" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": null, 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "str(45)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": null, 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [ 117 | "type(str(45))" 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": null, 123 | "metadata": {}, 124 | "outputs": [], 125 | "source": [ 126 | "str(True)" 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "metadata": {}, 132 | "source": [ 133 | "If you \"add\" strings together with a plus sign `+`, it will concatenate them:" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": null, 139 | "metadata": {}, 140 | "outputs": [], 141 | "source": [ 142 | "'IRE' + '/' + 'NICAR'" 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "#### Numbers and math\n", 150 | "\n", 151 | "Python recognizes a variety of numeric data types. Two of the most common are integers (whole numbers) and floats (numbers with decimals).\n", 152 | "\n", 153 | "Calling `int()` on a piece of numeric data (even if it's being stored as a string) will attempt to coerce it to an integer; calling `float()` will try to convert it to a float." 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": null, 159 | "metadata": {}, 160 | "outputs": [], 161 | "source": [ 162 | "12" 163 | ] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "execution_count": null, 168 | "metadata": {}, 169 | "outputs": [], 170 | "source": [ 171 | "12.4" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": null, 177 | "metadata": {}, 178 | "outputs": [], 179 | "source": [ 180 | "type(12)" 181 | ] 182 | }, 183 | { 184 | "cell_type": "code", 185 | "execution_count": null, 186 | "metadata": {}, 187 | "outputs": [], 188 | "source": [ 189 | "type(12.4)" 190 | ] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "execution_count": null, 195 | "metadata": {}, 196 | "outputs": [], 197 | "source": [ 198 | "int(35.6)" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "metadata": {}, 205 | "outputs": [], 206 | "source": [ 207 | "int('45')" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": null, 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [ 216 | "float(46)" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "metadata": {}, 223 | "outputs": [], 224 | "source": [ 225 | "float('45')" 226 | ] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "metadata": {}, 231 | "source": [ 232 | "You can do [basic math](https://www.digitalocean.com/community/tutorials/how-to-do-math-in-python-3-with-operators) in Python. You can also do [more advanced math](https://docs.python.org/3/library/math.html)." 233 | ] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": null, 238 | "metadata": {}, 239 | "outputs": [], 240 | "source": [ 241 | "4+2" 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": null, 247 | "metadata": {}, 248 | "outputs": [], 249 | "source": [ 250 | "10-9" 251 | ] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": null, 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [ 259 | "5*10" 260 | ] 261 | }, 262 | { 263 | "cell_type": "code", 264 | "execution_count": null, 265 | "metadata": {}, 266 | "outputs": [], 267 | "source": [ 268 | "1000/10" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "# ** raises a number to the power of another number\n", 278 | "5**2" 279 | ] 280 | }, 281 | { 282 | "cell_type": "markdown", 283 | "metadata": {}, 284 | "source": [ 285 | "#### Booleans\n", 286 | "\n", 287 | "Just like in Excel, which has `TRUE` and `FALSE` data types, Python has boolean data types. They are `True` and `False` -- note that only the first letter is capitalized, and they are not sandwiched between quotes.\n", 288 | "\n", 289 | "Boolean values are typically returned when you're evaluating some sort of conditional statement -- comparing values, checking to see if a string is inside another string or if a value is in a list, etc.\n", 290 | "\n", 291 | "[Python's comparison operators](https://docs.python.org/3/reference/expressions.html#comparisons) include:\n", 292 | "\n", 293 | "- `>` greater than\n", 294 | "- `<` less than\n", 295 | "- `>=` greater than or equal to\n", 296 | "- `<=` less than or equal to\n", 297 | "- `==` equal to\n", 298 | "- `!=` not equal to" 299 | ] 300 | }, 301 | { 302 | "cell_type": "code", 303 | "execution_count": null, 304 | "metadata": {}, 305 | "outputs": [], 306 | "source": [ 307 | "True" 308 | ] 309 | }, 310 | { 311 | "cell_type": "code", 312 | "execution_count": null, 313 | "metadata": {}, 314 | "outputs": [], 315 | "source": [ 316 | "False" 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": null, 322 | "metadata": {}, 323 | "outputs": [], 324 | "source": [ 325 | "4 > 6" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": null, 331 | "metadata": {}, 332 | "outputs": [], 333 | "source": [ 334 | "10 == 10" 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": null, 340 | "metadata": {}, 341 | "outputs": [], 342 | "source": [ 343 | "'crapulence' == 'Crapulence'" 344 | ] 345 | }, 346 | { 347 | "cell_type": "code", 348 | "execution_count": null, 349 | "metadata": {}, 350 | "outputs": [], 351 | "source": [ 352 | "type(True)" 353 | ] 354 | }, 355 | { 356 | "cell_type": "markdown", 357 | "metadata": {}, 358 | "source": [ 359 | "### Variable assignment\n", 360 | "\n", 361 | "The `=` sign assigns a value to a variable name that you choose. Later, you can retrieve that value by referencing its variable name. Variable names can be pretty much anything you want ([as long as you follow some basic rules](https://thehelloworldprogram.com/python/python-variable-assignment-statements-rules-conventions-naming/)).\n", 362 | "\n", 363 | "This can be a tricky concept at first! For more detail, [here's a pretty good explainer from Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-use-variables-in-python-3)." 364 | ] 365 | }, 366 | { 367 | "cell_type": "code", 368 | "execution_count": null, 369 | "metadata": {}, 370 | "outputs": [], 371 | "source": [ 372 | "my_name = 'Frank'" 373 | ] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": null, 378 | "metadata": {}, 379 | "outputs": [], 380 | "source": [ 381 | "my_name" 382 | ] 383 | }, 384 | { 385 | "cell_type": "markdown", 386 | "metadata": {}, 387 | "source": [ 388 | "You can also _reassign_ a different value to a variable name, though it's usually better practice to create a new variable." 389 | ] 390 | }, 391 | { 392 | "cell_type": "code", 393 | "execution_count": null, 394 | "metadata": {}, 395 | "outputs": [], 396 | "source": [ 397 | "my_name = 'Susan'" 398 | ] 399 | }, 400 | { 401 | "cell_type": "code", 402 | "execution_count": null, 403 | "metadata": {}, 404 | "outputs": [], 405 | "source": [ 406 | "my_name" 407 | ] 408 | }, 409 | { 410 | "cell_type": "markdown", 411 | "metadata": {}, 412 | "source": [ 413 | "A common thing to do is to \"save\" the results of an expression by assigning the result to a variable." 414 | ] 415 | }, 416 | { 417 | "cell_type": "code", 418 | "execution_count": null, 419 | "metadata": {}, 420 | "outputs": [], 421 | "source": [ 422 | "my_fav_number = 10 + 3" 423 | ] 424 | }, 425 | { 426 | "cell_type": "code", 427 | "execution_count": null, 428 | "metadata": {}, 429 | "outputs": [], 430 | "source": [ 431 | "my_fav_number" 432 | ] 433 | }, 434 | { 435 | "cell_type": "markdown", 436 | "metadata": {}, 437 | "source": [ 438 | "It's also common to refer to previously defined variables in an expression: " 439 | ] 440 | }, 441 | { 442 | "cell_type": "code", 443 | "execution_count": null, 444 | "metadata": {}, 445 | "outputs": [], 446 | "source": [ 447 | "nfl_teams = 32\n", 448 | "mlb_teams = 30\n", 449 | "nba_teams = 30\n", 450 | "nhl_teams = 31\n", 451 | "\n", 452 | "number_of_pro_sports_teams = nfl_teams + mlb_teams + nba_teams + nhl_teams" 453 | ] 454 | }, 455 | { 456 | "cell_type": "code", 457 | "execution_count": null, 458 | "metadata": {}, 459 | "outputs": [], 460 | "source": [ 461 | "number_of_pro_sports_teams" 462 | ] 463 | }, 464 | { 465 | "cell_type": "markdown", 466 | "metadata": {}, 467 | "source": [ 468 | "### String methods\n", 469 | "\n", 470 | "Let's go back to strings for a second. String objects have a number of useful [methods](https://docs.python.org/3/library/stdtypes.html#string-methods) -- let's use an example string to demonstrate a few common ones." 471 | ] 472 | }, 473 | { 474 | "cell_type": "code", 475 | "execution_count": null, 476 | "metadata": {}, 477 | "outputs": [], 478 | "source": [ 479 | "my_cool_string = ' Hello, friends!'" 480 | ] 481 | }, 482 | { 483 | "cell_type": "markdown", 484 | "metadata": {}, 485 | "source": [ 486 | "`upper()` converts the string to uppercase:" 487 | ] 488 | }, 489 | { 490 | "cell_type": "code", 491 | "execution_count": null, 492 | "metadata": {}, 493 | "outputs": [], 494 | "source": [ 495 | "my_cool_string.upper()" 496 | ] 497 | }, 498 | { 499 | "cell_type": "markdown", 500 | "metadata": {}, 501 | "source": [ 502 | "`lower()` converts to lowercase:" 503 | ] 504 | }, 505 | { 506 | "cell_type": "code", 507 | "execution_count": null, 508 | "metadata": {}, 509 | "outputs": [], 510 | "source": [ 511 | "my_cool_string.lower()" 512 | ] 513 | }, 514 | { 515 | "cell_type": "markdown", 516 | "metadata": {}, 517 | "source": [ 518 | "`replace()` will replace a piece of text with other text that you specify:" 519 | ] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "execution_count": null, 524 | "metadata": {}, 525 | "outputs": [], 526 | "source": [ 527 | "my_cool_string.replace('friends', 'enemies')" 528 | ] 529 | }, 530 | { 531 | "cell_type": "markdown", 532 | "metadata": {}, 533 | "source": [ 534 | "`count()` will count the number of occurrences of a character or group of characters: " 535 | ] 536 | }, 537 | { 538 | "cell_type": "code", 539 | "execution_count": null, 540 | "metadata": {}, 541 | "outputs": [], 542 | "source": [ 543 | "my_cool_string.count('H')" 544 | ] 545 | }, 546 | { 547 | "cell_type": "markdown", 548 | "metadata": {}, 549 | "source": [ 550 | "Note that `count()` is case-sensitive. If your task is \"count all the e's,\" convert your original string to upper or lowercase first:" 551 | ] 552 | }, 553 | { 554 | "cell_type": "code", 555 | "execution_count": null, 556 | "metadata": {}, 557 | "outputs": [], 558 | "source": [ 559 | "my_cool_string.upper().count('E')" 560 | ] 561 | }, 562 | { 563 | "cell_type": "markdown", 564 | "metadata": {}, 565 | "source": [ 566 | "[`split()`](https://docs.python.org/3/library/stdtypes.html#str.split) will split the string into a [_list_](#Lists) (more on these in a second) on a given delimiter (if you don't specify a delimiter, it'll default to splitting on a space):" 567 | ] 568 | }, 569 | { 570 | "cell_type": "code", 571 | "execution_count": null, 572 | "metadata": {}, 573 | "outputs": [], 574 | "source": [ 575 | "my_cool_string.split()" 576 | ] 577 | }, 578 | { 579 | "cell_type": "code", 580 | "execution_count": null, 581 | "metadata": {}, 582 | "outputs": [], 583 | "source": [ 584 | "my_cool_string.split(',')" 585 | ] 586 | }, 587 | { 588 | "cell_type": "code", 589 | "execution_count": null, 590 | "metadata": {}, 591 | "outputs": [], 592 | "source": [ 593 | "my_cool_string.split('Pitt')" 594 | ] 595 | }, 596 | { 597 | "cell_type": "markdown", 598 | "metadata": {}, 599 | "source": [ 600 | "`strip()` removes whitespace from either side of your string (but not internal whitespace):" 601 | ] 602 | }, 603 | { 604 | "cell_type": "code", 605 | "execution_count": null, 606 | "metadata": {}, 607 | "outputs": [], 608 | "source": [ 609 | "my_cool_string.strip()" 610 | ] 611 | }, 612 | { 613 | "cell_type": "markdown", 614 | "metadata": {}, 615 | "source": [ 616 | "You can use a cool thing called \"method chaining\" to combine methods -- just tack 'em onto the end. Let's say we wanted to strip whitespace from our string _and_ make it uppercase:" 617 | ] 618 | }, 619 | { 620 | "cell_type": "code", 621 | "execution_count": null, 622 | "metadata": {}, 623 | "outputs": [], 624 | "source": [ 625 | "my_cool_string.strip().upper()" 626 | ] 627 | }, 628 | { 629 | "cell_type": "markdown", 630 | "metadata": {}, 631 | "source": [ 632 | "Notice, however, that our original string is unchanged:" 633 | ] 634 | }, 635 | { 636 | "cell_type": "code", 637 | "execution_count": null, 638 | "metadata": {}, 639 | "outputs": [], 640 | "source": [ 641 | "my_cool_string" 642 | ] 643 | }, 644 | { 645 | "cell_type": "markdown", 646 | "metadata": {}, 647 | "source": [ 648 | "Why? Because we haven't assigned the results of anything we've done to a variable. A common thing to do, especially when you're cleaning data, would be to assign the results to a new variable:" 649 | ] 650 | }, 651 | { 652 | "cell_type": "code", 653 | "execution_count": null, 654 | "metadata": {}, 655 | "outputs": [], 656 | "source": [ 657 | "my_cool_string_clean = my_cool_string.strip().upper()" 658 | ] 659 | }, 660 | { 661 | "cell_type": "code", 662 | "execution_count": null, 663 | "metadata": {}, 664 | "outputs": [], 665 | "source": [ 666 | "my_cool_string_clean" 667 | ] 668 | }, 669 | { 670 | "cell_type": "markdown", 671 | "metadata": {}, 672 | "source": [ 673 | "### Comments\n", 674 | "A line with a comment -- a note that you don't want Python to interpret -- starts with a `#` sign. These are notes to collaborators and to your future self about what's happening at this point in your script, and why.\n", 675 | "\n", 676 | "Typically you'd put this on the line right above the line of code you're commenting on:" 677 | ] 678 | }, 679 | { 680 | "cell_type": "code", 681 | "execution_count": null, 682 | "metadata": {}, 683 | "outputs": [], 684 | "source": [ 685 | "avg_settlement = 40827348.34328237\n", 686 | "\n", 687 | "# coercing this to an int because we don't need any decimal precision\n", 688 | "int(avg_settlement)" 689 | ] 690 | }, 691 | { 692 | "cell_type": "markdown", 693 | "metadata": {}, 694 | "source": [ 695 | "Multi-line comments are sandwiched between triple quotes (or triple apostrophes):\n", 696 | "\n", 697 | "`'''\n", 698 | "this\n", 699 | "is a long\n", 700 | "comment\n", 701 | "'''`\n", 702 | "\n", 703 | "or\n", 704 | "\n", 705 | "`\"\"\"\n", 706 | "this\n", 707 | "is a long\n", 708 | "comment\n", 709 | "\"\"\"`" 710 | ] 711 | }, 712 | { 713 | "cell_type": "markdown", 714 | "metadata": {}, 715 | "source": [ 716 | "### The `print()` function\n", 717 | "\n", 718 | "So far, we've just been running the notebook cells to get the last value returned by the code we write. Using the [`print()`](https://docs.python.org/3/library/functions.html#print) function is a way to print specific things in your script to the screen. This function is handy for debugging.\n", 719 | "\n", 720 | "To print multiple things on the same line, separate them with a comma." 721 | ] 722 | }, 723 | { 724 | "cell_type": "code", 725 | "execution_count": null, 726 | "metadata": {}, 727 | "outputs": [], 728 | "source": [ 729 | "print('Hello!')" 730 | ] 731 | }, 732 | { 733 | "cell_type": "code", 734 | "execution_count": null, 735 | "metadata": {}, 736 | "outputs": [], 737 | "source": [ 738 | "print(my_name)" 739 | ] 740 | }, 741 | { 742 | "cell_type": "code", 743 | "execution_count": null, 744 | "metadata": {}, 745 | "outputs": [], 746 | "source": [ 747 | "print('Hello,', my_name)" 748 | ] 749 | }, 750 | { 751 | "cell_type": "markdown", 752 | "metadata": {}, 753 | "source": [ 754 | "## Collections of data\n", 755 | "\n", 756 | "Now we're going to talk about two ways you can use Python to group data into a collection: lists and dictionaries." 757 | ] 758 | }, 759 | { 760 | "cell_type": "markdown", 761 | "metadata": {}, 762 | "source": [ 763 | "### Lists\n", 764 | "\n", 765 | "A _list_ is a comma-separated list of items inside square brackets: `[]`.\n", 766 | "\n", 767 | "Here's a list of ingredients, each one a string, that together makes up a salsa recipe." 768 | ] 769 | }, 770 | { 771 | "cell_type": "code", 772 | "execution_count": null, 773 | "metadata": {}, 774 | "outputs": [], 775 | "source": [ 776 | "salsa_ingredients = ['tomato', 'onion', 'jalapeño', 'lime', 'cilantro']" 777 | ] 778 | }, 779 | { 780 | "cell_type": "markdown", 781 | "metadata": {}, 782 | "source": [ 783 | "To get an item out of a list, you'd refer to its numerical position in the list -- its _index_ (1, 2, 3, etc.) -- inside square brackets immediately following your reference to that list. In Python, as in many other programming languages, counting starts at 0. That means the first item in a list is item `0`." 784 | ] 785 | }, 786 | { 787 | "cell_type": "code", 788 | "execution_count": null, 789 | "metadata": {}, 790 | "outputs": [], 791 | "source": [ 792 | "salsa_ingredients[0]" 793 | ] 794 | }, 795 | { 796 | "cell_type": "code", 797 | "execution_count": null, 798 | "metadata": {}, 799 | "outputs": [], 800 | "source": [ 801 | "salsa_ingredients[1]" 802 | ] 803 | }, 804 | { 805 | "cell_type": "markdown", 806 | "metadata": {}, 807 | "source": [ 808 | "You can use _negative indexing_ to grab things from the right-hand side of the list -- and in fact, `[-1]` is a common idiom for getting \"the last item in a list\" when it's not clear how many items are in your list." 809 | ] 810 | }, 811 | { 812 | "cell_type": "code", 813 | "execution_count": null, 814 | "metadata": {}, 815 | "outputs": [], 816 | "source": [ 817 | "salsa_ingredients[-1]" 818 | ] 819 | }, 820 | { 821 | "cell_type": "markdown", 822 | "metadata": {}, 823 | "source": [ 824 | "If you wanted to get a slice of multiple items out of your list, you'd use colons (just like in Excel, kind of!).\n", 825 | "\n", 826 | "If you wanted to get the first three items, you'd do this:" 827 | ] 828 | }, 829 | { 830 | "cell_type": "code", 831 | "execution_count": null, 832 | "metadata": {}, 833 | "outputs": [], 834 | "source": [ 835 | "salsa_ingredients[0:3]" 836 | ] 837 | }, 838 | { 839 | "cell_type": "markdown", 840 | "metadata": {}, 841 | "source": [ 842 | "You could also have left off the initial 0 -- when you leave out the first number, Python defaults to \"the first item in the list.\" In the same way, if you leave off the last number, Python defaults to \"the last item in the list.\"" 843 | ] 844 | }, 845 | { 846 | "cell_type": "code", 847 | "execution_count": null, 848 | "metadata": {}, 849 | "outputs": [], 850 | "source": [ 851 | "salsa_ingredients[:3]" 852 | ] 853 | }, 854 | { 855 | "cell_type": "markdown", 856 | "metadata": {}, 857 | "source": [ 858 | "Note, too, that this slice is giving us items 0, 1 and 2. The `3` in our slice is the first item we _don't_ want. That can be kind of confusing at first. Let's try a few more:" 859 | ] 860 | }, 861 | { 862 | "cell_type": "code", 863 | "execution_count": null, 864 | "metadata": {}, 865 | "outputs": [], 866 | "source": [ 867 | "# everything in the list except the first item\n", 868 | "salsa_ingredients[1:]" 869 | ] 870 | }, 871 | { 872 | "cell_type": "code", 873 | "execution_count": null, 874 | "metadata": {}, 875 | "outputs": [], 876 | "source": [ 877 | "# the second, third and fourth items\n", 878 | "salsa_ingredients[1:4]" 879 | ] 880 | }, 881 | { 882 | "cell_type": "code", 883 | "execution_count": null, 884 | "metadata": {}, 885 | "outputs": [], 886 | "source": [ 887 | "# the last two items\n", 888 | "salsa_ingredients[-2:]" 889 | ] 890 | }, 891 | { 892 | "cell_type": "markdown", 893 | "metadata": {}, 894 | "source": [ 895 | "To see how many items are in a list, use the `len()` function:" 896 | ] 897 | }, 898 | { 899 | "cell_type": "code", 900 | "execution_count": null, 901 | "metadata": {}, 902 | "outputs": [], 903 | "source": [ 904 | "len(salsa_ingredients)" 905 | ] 906 | }, 907 | { 908 | "cell_type": "markdown", 909 | "metadata": {}, 910 | "source": [ 911 | "To add an item to a list, use the [`append()`](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists) method:" 912 | ] 913 | }, 914 | { 915 | "cell_type": "code", 916 | "execution_count": null, 917 | "metadata": {}, 918 | "outputs": [], 919 | "source": [ 920 | "salsa_ingredients" 921 | ] 922 | }, 923 | { 924 | "cell_type": "code", 925 | "execution_count": null, 926 | "metadata": {}, 927 | "outputs": [], 928 | "source": [ 929 | "salsa_ingredients.append('mayonnaise')" 930 | ] 931 | }, 932 | { 933 | "cell_type": "code", 934 | "execution_count": null, 935 | "metadata": {}, 936 | "outputs": [], 937 | "source": [ 938 | "salsa_ingredients" 939 | ] 940 | }, 941 | { 942 | "cell_type": "markdown", 943 | "metadata": {}, 944 | "source": [ 945 | "Haha _gross_. To remove an item from a list, use the `pop()` method. If you don't specify the index number of the item you want to pop out, it will default to \"the last item.\"" 946 | ] 947 | }, 948 | { 949 | "cell_type": "code", 950 | "execution_count": null, 951 | "metadata": {}, 952 | "outputs": [], 953 | "source": [ 954 | "salsa_ingredients.pop()" 955 | ] 956 | }, 957 | { 958 | "cell_type": "code", 959 | "execution_count": null, 960 | "metadata": { 961 | "scrolled": true 962 | }, 963 | "outputs": [], 964 | "source": [ 965 | "salsa_ingredients" 966 | ] 967 | }, 968 | { 969 | "cell_type": "markdown", 970 | "metadata": {}, 971 | "source": [ 972 | "You can use the [`in` and `not in`](https://docs.python.org/3/reference/expressions.html#membership-test-operations) expressions to test membership in a list (will return a boolean):" 973 | ] 974 | }, 975 | { 976 | "cell_type": "code", 977 | "execution_count": null, 978 | "metadata": {}, 979 | "outputs": [], 980 | "source": [ 981 | "'lime' in salsa_ingredients" 982 | ] 983 | }, 984 | { 985 | "cell_type": "code", 986 | "execution_count": null, 987 | "metadata": {}, 988 | "outputs": [], 989 | "source": [ 990 | "'cilantro' not in salsa_ingredients" 991 | ] 992 | }, 993 | { 994 | "cell_type": "markdown", 995 | "metadata": {}, 996 | "source": [ 997 | "### Dictionaries\n", 998 | "\n", 999 | "A _dictionary_ is a comma-separated list of key/value pairs inside curly brackets: `{}`. Let's make an entire salsa recipe:" 1000 | ] 1001 | }, 1002 | { 1003 | "cell_type": "code", 1004 | "execution_count": null, 1005 | "metadata": {}, 1006 | "outputs": [], 1007 | "source": [ 1008 | "salsa = {\n", 1009 | " 'ingredients': salsa_ingredients,\n", 1010 | " 'instructions': 'Chop up all the ingredients and cook them for awhile.',\n", 1011 | " 'oz_made': 12\n", 1012 | "}" 1013 | ] 1014 | }, 1015 | { 1016 | "cell_type": "markdown", 1017 | "metadata": {}, 1018 | "source": [ 1019 | "To retrieve a value from a dictionary, you'd refer to the name of its key inside square brackets `[]` immediately after your reference to the dictionary:" 1020 | ] 1021 | }, 1022 | { 1023 | "cell_type": "code", 1024 | "execution_count": null, 1025 | "metadata": {}, 1026 | "outputs": [], 1027 | "source": [ 1028 | "salsa['oz_made']" 1029 | ] 1030 | }, 1031 | { 1032 | "cell_type": "code", 1033 | "execution_count": null, 1034 | "metadata": {}, 1035 | "outputs": [], 1036 | "source": [ 1037 | "salsa['ingredients']" 1038 | ] 1039 | }, 1040 | { 1041 | "cell_type": "markdown", 1042 | "metadata": {}, 1043 | "source": [ 1044 | "To add a new key/value pair to a dictionary, assign a new key to the dictionary inside square brackets and set the value of that key with `=`:" 1045 | ] 1046 | }, 1047 | { 1048 | "cell_type": "code", 1049 | "execution_count": null, 1050 | "metadata": {}, 1051 | "outputs": [], 1052 | "source": [ 1053 | "salsa['tastes_great'] = True" 1054 | ] 1055 | }, 1056 | { 1057 | "cell_type": "code", 1058 | "execution_count": null, 1059 | "metadata": {}, 1060 | "outputs": [], 1061 | "source": [ 1062 | "salsa" 1063 | ] 1064 | }, 1065 | { 1066 | "cell_type": "markdown", 1067 | "metadata": {}, 1068 | "source": [ 1069 | "To delete a key/value pair out of a dictionary, use the `del` command and reference the key:" 1070 | ] 1071 | }, 1072 | { 1073 | "cell_type": "code", 1074 | "execution_count": null, 1075 | "metadata": {}, 1076 | "outputs": [], 1077 | "source": [ 1078 | "del salsa['tastes_great']" 1079 | ] 1080 | }, 1081 | { 1082 | "cell_type": "code", 1083 | "execution_count": null, 1084 | "metadata": {}, 1085 | "outputs": [], 1086 | "source": [ 1087 | "salsa" 1088 | ] 1089 | }, 1090 | { 1091 | "cell_type": "markdown", 1092 | "metadata": {}, 1093 | "source": [ 1094 | "### Indentation\n", 1095 | "\n", 1096 | "Whitespace matters in Python. Sometimes you'll need to indent bits of code to make things work. This can be confusing! `IndentationError`s are common even for experienced programmers. (FWIW, Jupyter will try to be helpful and insert the correct amount of \"significant whitespace\" for you.)\n", 1097 | "\n", 1098 | "You can use tabs or spaces, just don't mix them. [The Python style guide](https://www.python.org/dev/peps/pep-0008/) recommends indenting your code in groups of four spaces, so that's what we'll use." 1099 | ] 1100 | }, 1101 | { 1102 | "cell_type": "markdown", 1103 | "metadata": {}, 1104 | "source": [ 1105 | "### `for` loops\n", 1106 | "\n", 1107 | "You would use a `for` loop to iterate over a collection of things. The statement begins with the keyword `for` (lowercase), then a temporary `variable_name` of your choice to represent each item as you loop through the collection, then the Python keyword `in`, then the collection you're looping over (or its variable name), then a colon, then the indented block of code with instructions about what to do with each item in the collection.\n", 1108 | "\n", 1109 | "Let's say we have a list of numbers that we assign to the variable `list_of_numbers`." 1110 | ] 1111 | }, 1112 | { 1113 | "cell_type": "code", 1114 | "execution_count": null, 1115 | "metadata": {}, 1116 | "outputs": [], 1117 | "source": [ 1118 | "list_of_numbers = [1, 2, 3, 4, 5, 6]" 1119 | ] 1120 | }, 1121 | { 1122 | "cell_type": "markdown", 1123 | "metadata": {}, 1124 | "source": [ 1125 | "We could loop over the list and print out each number:" 1126 | ] 1127 | }, 1128 | { 1129 | "cell_type": "code", 1130 | "execution_count": null, 1131 | "metadata": {}, 1132 | "outputs": [], 1133 | "source": [ 1134 | "for number in list_of_numbers:\n", 1135 | " print(number)" 1136 | ] 1137 | }, 1138 | { 1139 | "cell_type": "markdown", 1140 | "metadata": {}, 1141 | "source": [ 1142 | "We could print out each number _times 6_:" 1143 | ] 1144 | }, 1145 | { 1146 | "cell_type": "code", 1147 | "execution_count": null, 1148 | "metadata": {}, 1149 | "outputs": [], 1150 | "source": [ 1151 | "for number in list_of_numbers:\n", 1152 | " print(number*6)" 1153 | ] 1154 | }, 1155 | { 1156 | "cell_type": "markdown", 1157 | "metadata": {}, 1158 | "source": [ 1159 | "... whatever you need to do in you loop. Note that the variable name `number` in our loop is totally arbitrary. This also would work:" 1160 | ] 1161 | }, 1162 | { 1163 | "cell_type": "code", 1164 | "execution_count": null, 1165 | "metadata": {}, 1166 | "outputs": [], 1167 | "source": [ 1168 | "for banana in list_of_numbers:\n", 1169 | " print(banana)" 1170 | ] 1171 | }, 1172 | { 1173 | "cell_type": "markdown", 1174 | "metadata": {}, 1175 | "source": [ 1176 | "It can be hard, at first, to figure out what's a \"Python word\" and what's a variable name that you get to define. This comes with practice." 1177 | ] 1178 | }, 1179 | { 1180 | "cell_type": "markdown", 1181 | "metadata": {}, 1182 | "source": [ 1183 | "Strings are iterable, too. Let's loop over the letters in a sentence:" 1184 | ] 1185 | }, 1186 | { 1187 | "cell_type": "code", 1188 | "execution_count": null, 1189 | "metadata": {}, 1190 | "outputs": [], 1191 | "source": [ 1192 | "sentence = 'Hello, IRE/NICAR!'\n", 1193 | "\n", 1194 | "for letter in sentence:\n", 1195 | " print(letter)" 1196 | ] 1197 | }, 1198 | { 1199 | "cell_type": "markdown", 1200 | "metadata": {}, 1201 | "source": [ 1202 | "To this point: Strings are iterable, like lists, so you can use the same kinds of methods:" 1203 | ] 1204 | }, 1205 | { 1206 | "cell_type": "code", 1207 | "execution_count": null, 1208 | "metadata": {}, 1209 | "outputs": [], 1210 | "source": [ 1211 | "# get the first five characters\n", 1212 | "sentence[:5]" 1213 | ] 1214 | }, 1215 | { 1216 | "cell_type": "code", 1217 | "execution_count": null, 1218 | "metadata": {}, 1219 | "outputs": [], 1220 | "source": [ 1221 | "# get the length of the sentence\n", 1222 | "len(sentence)" 1223 | ] 1224 | }, 1225 | { 1226 | "cell_type": "code", 1227 | "execution_count": null, 1228 | "metadata": {}, 1229 | "outputs": [], 1230 | "source": [ 1231 | "'Hello' in sentence" 1232 | ] 1233 | }, 1234 | { 1235 | "cell_type": "markdown", 1236 | "metadata": {}, 1237 | "source": [ 1238 | "You can iterate over dictionaries, too -- just remember that dictionaries _don't keep track of the order that items were added to it_.\n", 1239 | "\n", 1240 | "When you're looping over a dictionary, the variable name in your `for` loop will refer to the keys. Let's loop over our `salsa` dictionary from up above to see what I mean." 1241 | ] 1242 | }, 1243 | { 1244 | "cell_type": "code", 1245 | "execution_count": null, 1246 | "metadata": {}, 1247 | "outputs": [], 1248 | "source": [ 1249 | "for key in salsa:\n", 1250 | " print(key)" 1251 | ] 1252 | }, 1253 | { 1254 | "cell_type": "markdown", 1255 | "metadata": {}, 1256 | "source": [ 1257 | "To get the _value_ of a dictionary item in a for loop, you'd need to use the key to retrieve it from the dictionary:" 1258 | ] 1259 | }, 1260 | { 1261 | "cell_type": "code", 1262 | "execution_count": null, 1263 | "metadata": {}, 1264 | "outputs": [], 1265 | "source": [ 1266 | "for key in salsa:\n", 1267 | " print(salsa[key])" 1268 | ] 1269 | }, 1270 | { 1271 | "cell_type": "markdown", 1272 | "metadata": {}, 1273 | "source": [ 1274 | "### `if` statements\n", 1275 | "Just like in Excel, you can use the \"if\" keyword to handle conditional logic.\n", 1276 | "\n", 1277 | "These statements begin with the keyword `if` (lowercase), then the condition to evaluate, then a colon, then a new line with a block of indented code to execute if the condition resolves to `True`." 1278 | ] 1279 | }, 1280 | { 1281 | "cell_type": "code", 1282 | "execution_count": null, 1283 | "metadata": {}, 1284 | "outputs": [], 1285 | "source": [ 1286 | "if 4 < 6:\n", 1287 | " print('4 is less than 6')" 1288 | ] 1289 | }, 1290 | { 1291 | "cell_type": "markdown", 1292 | "metadata": {}, 1293 | "source": [ 1294 | "You can also add an `else` statement (and a colon) with an indented block of code you want to run if the condition resolves to `False`." 1295 | ] 1296 | }, 1297 | { 1298 | "cell_type": "code", 1299 | "execution_count": null, 1300 | "metadata": {}, 1301 | "outputs": [], 1302 | "source": [ 1303 | "if 4 > 6:\n", 1304 | " print('4 is greater than 6?!')\n", 1305 | "else:\n", 1306 | " print('4 is not greater than 6.')" 1307 | ] 1308 | }, 1309 | { 1310 | "cell_type": "markdown", 1311 | "metadata": {}, 1312 | "source": [ 1313 | "If you need to, you can add multiple conditions with `elif`." 1314 | ] 1315 | }, 1316 | { 1317 | "cell_type": "code", 1318 | "execution_count": null, 1319 | "metadata": {}, 1320 | "outputs": [], 1321 | "source": [ 1322 | "HOME_SCORE = 6\n", 1323 | "AWAY_SCORE = 8\n", 1324 | "\n", 1325 | "if HOME_SCORE > AWAY_SCORE:\n", 1326 | " print('we won!')\n", 1327 | "elif HOME_SCORE == AWAY_SCORE:\n", 1328 | " print('we tied!')\n", 1329 | "else:\n", 1330 | " print('we lost!')" 1331 | ] 1332 | } 1333 | ], 1334 | "metadata": { 1335 | "kernelspec": { 1336 | "display_name": "Python 3 (ipykernel)", 1337 | "language": "python", 1338 | "name": "python3" 1339 | }, 1340 | "language_info": { 1341 | "codemirror_mode": { 1342 | "name": "ipython", 1343 | "version": 3 1344 | }, 1345 | "file_extension": ".py", 1346 | "mimetype": "text/x-python", 1347 | "name": "python", 1348 | "nbconvert_exporter": "python", 1349 | "pygments_lexer": "ipython3", 1350 | "version": "3.13.0" 1351 | } 1352 | }, 1353 | "nbformat": 4, 1354 | "nbformat_minor": 4 1355 | } 1356 | -------------------------------------------------------------------------------- /mlb-salaries-usa-today-2024.csv: -------------------------------------------------------------------------------- 1 | year,name_last,name_first,team,position,salary,years,total_value,avg_annual 2 | 2024,Miller,Erik,Giants,LHP,740000,,, 3 | 2024,McCann,Kyle,Athletics,C,740000,,, 4 | 2024,Roupp,Landen,Giants,RHP,740000,,, 5 | 2024,Duarte,Daniel,Twins,RHP,740000,,, 6 | 2024,Murphy,Penn,Astros,RHP,740000,,, 7 | 2024,Chavez,Jesse,Braves,RHP,740000,,, 8 | 2024,Dunn,Oliver,Brewers,INF,740000,,, 9 | 2024,Barnhart,Tucker,Diamondbacks,C,740000,,, 10 | 2024,Jones,Jared,Pirates,RHP,740000,,, 11 | 2024,Langford,Wyatt,Rangers,OF,740000,,, 12 | 2024,Shenton,Austin,Rays,3B,740000,,, 13 | 2024,Marte,Noelvi,Reds,3B,740000,,, 14 | 2024,Leasure,Jordan,White Sox,RHP,740000,,, 15 | 2024,Boyle,Joe,Athletics,RHP,740000,,, 16 | 2024,Butler,Lawrence,Athletics,OF,740000,,, 17 | 2024,Gelof,Zack,Athletics,2B,740000,,, 18 | 2024,Hernaiz,Darell,Athletics,INF,740000,,, 19 | 2024,Medina,Luis,Athletics,RHP,740000,,, 20 | 2024,Miller,Mason,Athletics,RHP,740000,,, 21 | 2024,Muller,Kyle,Athletics,LHP,740000,,, 22 | 2024,Spence,Mitch,Athletics,RHP,740000,,, 23 | 2024,Perdomo,Angel,Braves,LHP,740000,,, 24 | 2024,Fernandez,Ryan,Cardinals,RHP,740000,,, 25 | 2024,Scott II,Victor,Cardinals,OF,740000,,, 26 | 2024,Alexander,Blaze,Diamondbacks,INF,740000,,, 27 | 2024,Martinez,Angel,Guardians,INF,740000,,, 28 | 2024,Smith,Cade,Guardians,RHP,740000,,, 29 | 2024,Nunez,Nasim,Nationals,SS,740000,,, 30 | 2024,Kolek,Stephen,Padres,RHP,740000,,, 31 | 2024,Merrill,Jackson,Padres,OF,740000,,, 32 | 2024,Pauley,Graham,Padres,3B,740000,,, 33 | 2024,Coleman,Carson,Rangers,RHP,740000,,, 34 | 2024,Mata,Bryan,Red Sox,RHP,740000,,, 35 | 2024,Slaten,Justin,Red Sox,RHP,740000,,, 36 | 2024,Encarnacion-Strand,Christian,Reds,1B,740000,,, 37 | 2024,Molina,Anthony,Rockies,RHP,740000,,, 38 | 2024,Sauer,Matt,Royals,RHP,740000,,, 39 | 2024,Funderburk,Kody,Twins,LHP,740000,,, 40 | 2024,Drohan,Shane,White Sox,LHP,740000,,, 41 | 2024,Beeter,Clayton,Yankees,RHP,740000,,, 42 | 2024,Rocchio,Brayan,Guardians,SS,740200,,, 43 | 2024,Cavalli,Cade,Nationals,RHP,740200,,, 44 | 2024,Berroa,Prelander,White Sox,RHP,740350,,, 45 | 2024,Shewmake,Braden,White Sox,SS,740350,,, 46 | 2024,O'Brien,Riley,Cardinals,RHP,740450,,, 47 | 2024,Kilian,Caleb,Cubs,RHP,740500,,, 48 | 2024,Little,Luke,Cubs,LHP,740500,,, 49 | 2024,Simpson,Josh,Marlins,LHP,740500,,, 50 | 2024,Garcia,Deivi,White Sox,RHP,740550,,, 51 | 2024,Gaddis,Hunter,Guardians,RHP,740700,,, 52 | 2024,Herrin,Tim,Guardians,LHP,740800,,, 53 | 2024,Latz,Jacob,Rangers,LHP,741000,,, 54 | 2024,Fry,David,Guardians,C,741100,,, 55 | 2024,Bolton,Cody,Mariners,RHP,741100,,, 56 | 2024,Jones,Jahmai,Yankees,INF,741200,,, 57 | 2024,Small,Ethan,Giants,LHP,741300,,, 58 | 2024,Hancock,Emerson,Mariners,RHP,741300,,, 59 | 2024,Ortiz,Joey,Brewers,INF,741500,,, 60 | 2024,Busch,Michael,Cubs,DH,741500,,, 61 | 2024,Wicks,Jordan,Cubs,LHP,741500,,, 62 | 2024,Dubin,Shawn,Astros,RHP,741600,,, 63 | 2024,Siani,Mike,Cardinals,OF,741650,,, 64 | 2024,Hudson,Bryan,Brewers,LHP,741700,,, 65 | 2024,Waldron,Matt,Padres,RHP,741800,,, 66 | 2024,Lee,Korey,White Sox,C,741850,,, 67 | 2024,Fitzgerald,Tyler,Giants,INF,741875,,, 68 | 2024,Loftin,Nick,Royals,INF,741900,,, 69 | 2024,Freeman,Tyler,Guardians,OF,742000,,, 70 | 2024,Cronin,Declan,Marlins,RHP,742000,,, 71 | 2024,Sanchez,Sixto,Marlins,RHP,742000,,, 72 | 2024,Grissom,Vaughn,Red Sox,2B,742000,,, 73 | 2024,Doyle,Brenton,Rockies,OF,742000,,, 74 | 2024,Toglia,Michael,Rockies,1B,742000,,, 75 | 2024,Vodnik,Victor,Rockies,RHP,742000,,, 76 | 2024,Kessinger,Grae,Astros,INF,742100,,, 77 | 2024,Naylor,Bo,Guardians,C,742100,,, 78 | 2024,Williams,Gavin,Guardians,RHP,742100,,, 79 | 2024,Rom,Drew,Cardinals,LHP,742200,,, 80 | 2024,Winn,Masyn,Cardinals,SS,742250,,, 81 | 2024,Sousa,Bennett,Astros,LHP,742300,,, 82 | 2024,Mead,Curtis,Rays,INF,742300,,, 83 | 2024,DeLuca,Jonny,Rays,OF,742400,,, 84 | 2024,Thompson,Bubba,Reds,OF,742500,,, 85 | 2024,Hurt,Kyle,Dodgers,RHP,742500,,, 86 | 2024,Stone,Gavin,Dodgers,RHP,742500,,, 87 | 2024,Kerkering,Orion,Phillies,RHP,742500,,, 88 | 2024,Abbott,Andrew,Reds,LHP,742500,,, 89 | 2024,De La Cruz,Elly,Reds,SS,742500,,, 90 | 2024,McLain,Matt,Reds,2B,742500,,, 91 | 2024,Williamson,Brandon,Reds,LHP,742500,,, 92 | 2024,Vespi,Nick,Orioles,LHP,742700,,, 93 | 2024,Garcia,Robert,Nationals,LHP,742800,,, 94 | 2024,Cowser,Colton,Orioles,OF,742800,,, 95 | 2024,Aranda,Jonathan,Rays,INF,742800,,, 96 | 2024,Fletcher,Dominic,White Sox,OF,742900,,, 97 | 2024,Meyer,Max,Marlins,RHP,743000,,, 98 | 2024,Kowar,Jackson,Mariners,RHP,743000,,, 99 | 2024,Edwards,Xavier,Marlins,2B,743000,,, 100 | 2024,Ferrer,Jose,Nationals,LHP,743000,,, 101 | 2024,Rodriguez,Yerry,Rangers,RHP,743000,,, 102 | 2024,Herrera,Ivan,Cardinals,C,743150,,, 103 | 2024,Moore,McKinley,Yankees,RHP,743250,,, 104 | 2024,Bradley,Taj,Rays,RHP,743300,,, 105 | 2024,Mauricio,Ronny,Mets,INF,743500,,, 106 | 2024,Murphy,Chris,Red Sox,LHP,743500,,, 107 | 2024,Rafaela,Ceddanne,Red Sox,OF,743500,,, 108 | 2024,Valdez,Enmanuel,Red Sox,2B,743500,,, 109 | 2024,Weissert,Greg,Red Sox,RHP,743500,,, 110 | 2024,Jarvis,Bryce,Diamondbacks,RHP,743600,,, 111 | 2024,Baz,Shane,Rays,RHP,743600,,, 112 | 2024,Gipson-Long,Sawyer,Tigers,RHP,743600,,, 113 | 2024,Canzone,Dominic,Mariners,OF,743700,,, 114 | 2024,Harrison,Kyle,Giants,LHP,743750,,, 115 | 2024,Hjelle,Sean,Giants,RHP,743750,,, 116 | 2024,Winn,Keaton,Giants,RHP,743750,,, 117 | 2024,Blanco,Dairon,Royals,OF,743750,,, 118 | 2024,Ortiz,Luis,Phillies,RHP,744000,,, 119 | 2024,Arias,Gabriel,Guardians,INF,744100,,, 120 | 2024,Hall,DL,Brewers,LHP,744200,,, 121 | 2024,Mitchell,Garrett,Brewers,OF,744300,,, 122 | 2024,Allen,Logan,Guardians,LHP,744300,,, 123 | 2024,Curry,Xzavion,Guardians,RHP,744400,,, 124 | 2024,Rosario,Eguy,Padres,INF,744400,,, 125 | 2024,Fermin,Freddy,Royals,C,744500,,, 126 | 2024,Weiss,Zack,Twins,RHP,744550,,, 127 | 2024,Marsh,Alec,Royals,RHP,744750,,, 128 | 2024,Schneider,Davis,Blue Jays,INF,744900,,, 129 | 2024,Brennan,Will,Guardians,OF,744900,,, 130 | 2024,Pepiot,Ryan,Rays,RHP,744900,,, 131 | 2024,Bride,Jonah,Marlins,INF,745000,,, 132 | 2024,Trejo,Alan,Rockies,2B,745000,,, 133 | 2024,Allen,Nick,Athletics,SS,745000,,, 134 | 2024,Bleday,JJ,Athletics,OF,745000,,, 135 | 2024,Langeliers,Shea,Athletics,C,745000,,, 136 | 2024,Noda,Ryan,Athletics,1B,745000,,, 137 | 2024,Ruiz,Esteury,Athletics,OF,745000,,, 138 | 2024,Sears,J.P.,Athletics,LHP,745000,,, 139 | 2024,Tarnok,Freddy,Athletics,RHP,745000,,, 140 | 2024,Waldichuk,Ken,Athletics,LHP,745000,,, 141 | 2024,Rojas,Johan,Phillies,OF,745000,,, 142 | 2024,Rodriguez,Endy,Pirates,C,745000,,, 143 | 2024,Triolo,Jared,Pirates,2B,745000,,, 144 | 2024,Williams,Alika,Pirates,INF,745000,,, 145 | 2024,Carter,Evan,Rangers,OF,745000,,, 146 | 2024,Bird,Jake,Rockies,RHP,745000,,, 147 | 2024,Feltner,Ryan,Rockies,RHP,745000,,, 148 | 2024,Jones,Nolan,Rockies,OF,745000,,, 149 | 2024,Lawrence,Justin,Rockies,RHP,745000,,, 150 | 2024,Montero,Elehuris,Rockies,1B,745000,,, 151 | 2024,Pinto,Rene,Rays,C,745100,,, 152 | 2024,Palacios,Richie,Rays,OF,745200,,, 153 | 2024,Varland,Louie,Twins,RHP,745400,,, 154 | 2024,Wallner,Matt,Twins,OF,745550,,, 155 | 2024,Irvin,Jake,Nationals,RHP,745600,,, 156 | 2024,Bibee,Tanner,Guardians,RHP,745700,,, 157 | 2024,Azocar,Jose,Padres,OF,745700,,, 158 | 2024,Lewis,Royce,Twins,3B,745700,,, 159 | 2024,McArthur,James,Royals,RHP,745750,,, 160 | 2024,Brujan,Vidal,Marlins,OF,745800,,, 161 | 2024,Westburg,Jordan,Orioles,2B,745800,,, 162 | 2024,Dominguez,Jasson,Yankees,OF,745800,,, 163 | 2024,Mastrobuoni,Miles,Cubs,INF,746000,,, 164 | 2024,Soriano,George,Marlins,RHP,746000,,, 165 | 2024,Brito,Jhony,Padres,RHP,746000,,, 166 | 2024,Marcano,Tucupita,Padres,SS,746000,,, 167 | 2024,Campbell,Isaiah,Red Sox,RHP,746000,,, 168 | 2024,Frelick,Sal,Brewers,OF,746500,,, 169 | 2024,Amaya,Miguel,Cubs,C,746500,,, 170 | 2024,Avila,Pedro,Padres,RHP,746600,,, 171 | 2024,Faedo,Alex,Tigers,RHP,746600,,, 172 | 2024,Wentz,Joey,Tigers,LHP,746700,,, 173 | 2024,Julien,Edouard,Twins,2B,746750,,, 174 | 2024,Cleavinger,Garrett,Rays,LHP,746900,,, 175 | 2024,Meadows,Parker,Tigers,OF,746900,,, 176 | 2024,Otto,Glenn,Padres,RHP,747000,,, 177 | 2024,Velazquez,Nelson,Royals,OF,747000,,, 178 | 2024,Liberatore,Matthew,Cardinals,LHP,747200,,, 179 | 2024,Duran,Jhoan,Twins,RHP,747200,,, 180 | 2024,Scholtens,Jesse,White Sox,RHP,747250,,, 181 | 2024,Snider,Collin,Mariners,RHP,747300,,, 182 | 2024,Short,Zack,Mets,INF,747300,,, 183 | 2024,Mushinski,Parker,Astros,LHP,747400,,, 184 | 2024,Uribe,Abner,Brewers,RHP,747400,,, 185 | 2024,Walker,Jordan,Cardinals,OF,747450,,, 186 | 2024,Bailey,Patrick,Giants,C,747500,,, 187 | 2024,Beck,Tristan,Giants,RHP,747500,,, 188 | 2024,Walker,Ryan,Giants,RHP,747500,,, 189 | 2024,Davis,Henry,Pirates,C,747500,,, 190 | 2024,Mlodzinski,Carmen,Pirates,RHP,747500,,, 191 | 2024,Ortiz,Luis,Pirates,RHP,747500,,, 192 | 2024,Francis,Bowden,Blue Jays,RHP,748000,,, 193 | 2024,Perez,Eury,Marlins,RHP,748000,,, 194 | 2024,Turang,Brice,Brewers,2B,748200,,, 195 | 2024,Zerpa,Angel,Royals,LHP,748250,,, 196 | 2024,Frias,Luis,Diamondbacks,RHP,748300,,, 197 | 2024,Rodriguez,Grayson,Orioles,RHP,748300,,, 198 | 2024,Ortega,Oliver,Astros,RHP,748500,,, 199 | 2024,Florial,Estevan,Guardians,OF,748500,,, 200 | 2024,Bradford,Cody,Rangers,LHP,748500,,, 201 | 2024,Baumann,Michael,Orioles,RHP,748900,,, 202 | 2024,Woo,Bryan,Mariners,RHP,749000,,, 203 | 2024,Thompson,Mason,Nationals,RHP,749200,,, 204 | 2024,Patino,Luis,Padres,RHP,749400,,, 205 | 2024,Sands,Cole,Twins,RHP,749450,,, 206 | 2024,Smith,Josh,Rangers,INF,749500,,, 207 | 2024,Abreu,Wilyer,Red Sox,OF,749500,,, 208 | 2024,Parsons,Wes,Blue Jays,RHP,749600,,, 209 | 2024,Gore,MacKenzie,Nationals,LHP,749600,,, 210 | 2024,Jameson,Drey,Diamondbacks,RHP,749700,,, 211 | 2024,Blanco,Ronel,Astros,RHP,749800,,, 212 | 2024,Gil,Luis,Yankees,RHP,750000,,, 213 | 2024,Bachman,Sam,Angels,RHP,750000,,, 214 | 2024,Neto,Zach,Angels,SS,750000,,, 215 | 2024,Schanuel,Nolan,Angels,1B,750000,,, 216 | 2024,Silseth,Chase,Angels,RHP,750000,,, 217 | 2024,Stefanic,Michael,Angels,INF,750000,,, 218 | 2024,Zuniga,Guillermo,Angels,RHP,750000,,, 219 | 2024,Erceg,Lucas,Athletics,RHP,750000,,, 220 | 2024,Jimenez,Dany,Athletics,RHP,750000,,, 221 | 2024,Kelly,Michael,Athletics,RHP,750000,,, 222 | 2024,Rooker,Brent,Athletics,OF,750000,,, 223 | 2024,Wall,Forrest,Braves,OF,750000,,, 224 | 2024,Miller,Bobby,Dodgers,RHP,750000,,, 225 | 2024,Sheehan,Emmet,Dodgers,RHP,750000,,, 226 | 2024,Lively,Ben,Guardians,RHP,750000,,, 227 | 2024,Santos,Gregory,Mariners,RHP,750000,,, 228 | 2024,Baty,Brett,Mets,3B,750000,,, 229 | 2024,Kranick,Max,Mets,RHP,750000,,, 230 | 2024,Marchan,Rafael,Phillies,C,750000,,, 231 | 2024,Ashcraft,Graham,Reds,RHP,750000,,, 232 | 2024,Benson,Will,Reds,OF,750000,,, 233 | 2024,Cruz,Fernando,Reds,RHP,750000,,, 234 | 2024,Fairchild,Stuart,Reds,OF,750000,,, 235 | 2024,Friedl,TJ,Reds,OF,750000,,, 236 | 2024,Martini,Nick,Reds,OF,750000,,, 237 | 2024,Steer,Spencer,Reds,OF,750000,,, 238 | 2024,Mears,Nick,Rockies,RHP,750000,,, 239 | 2024,Foster,Matt,White Sox,RHP,750000,,, 240 | 2024,Effross,Scott,Yankees,RHP,750000,,, 241 | 2024,Wells,Austin,Yankees,C,750000,,, 242 | 2024,Burleson,Alec,Cardinals,OF,750050,,, 243 | 2024,Hoeing,Bryan,Marlins,RHP,750500,,, 244 | 2024,Cosgrove,Tom,Padres,LHP,750500,,, 245 | 2024,Thompson,Zack,Cardinals,LHP,750850,,, 246 | 2024,Adams,Riley,Nationals,C,750900,,, 247 | 2024,Serven,Brian,Blue Jays,C,751000,,, 248 | 2024,Morgan,Eli,Guardians,RHP,751200,,, 249 | 2024,Garcia,Maikel,Royals,3B,751250,,, 250 | 2024,Marte,Yunior,Phillies,RHP,751500,,, 251 | 2024,Rucker,Michael,Phillies,RHP,751500,,, 252 | 2024,Caballero,Jose,Rays,SS,751700,,, 253 | 2024,Winder,Josh,Twins,RHP,751850,,, 254 | 2024,Wilson,Steven,White Sox,RHP,751900,,, 255 | 2024,Meneses,Joey,Nationals,DH,752000,,, 256 | 2024,Cano,Yennier,Orioles,RHP,752300,,, 257 | 2024,Olson,Reese,Tigers,RHP,752300,,, 258 | 2024,Abrams Jr.,CJ,Nationals,SS,752400,,, 259 | 2024,Monasterio,Andruw,Brewers,INF,752500,,, 260 | 2024,Miller,Bryce,Mariners,RHP,752600,,, 261 | 2024,Weathers,Ryan,Marlins,LHP,752600,,, 262 | 2024,Pasquantino,Vinnie,Royals,1B,752750,,, 263 | 2024,Brazoban,Huascar,Marlins,RHP,753000,,, 264 | 2024,Saucedo,Tayler,Mariners,LHP,753100,,, 265 | 2024,Speier,Gabe,Mariners,LHP,753300,,, 266 | 2024,Sanchez,Cristopher,Phillies,LHP,753500,,, 267 | 2024,Martinez,Seth,Astros,RHP,753600,,, 268 | 2024,Ragans,Cole,Royals,LHP,753750,,, 269 | 2024,Nardi,Andrew,Marlins,LHP,754000,,, 270 | 2024,Raley,Luke,Mariners,1B,754200,,, 271 | 2024,Peguero,Elvis,Brewers,RHP,754300,,, 272 | 2024,Pfaadt,Brandon,Diamondbacks,RHP,754400,,, 273 | 2024,Bradish,Kyle,Orioles,RHP,754500,,, 274 | 2024,Duran,Ezequiel,Rangers,INF,754500,,, 275 | 2024,Campusano,Luis,Padres,C,754700,,, 276 | 2024,Melendez,MJ,Royals,OF,754750,,, 277 | 2024,Assad,Javier,Cubs,RHP,755000,,, 278 | 2024,Warren,Austin,Giants,RHP,755000,,, 279 | 2024,Bae,Ji-hwan,Pirates,2B,755000,,, 280 | 2024,Contreras,Roansy,Pirates,RHP,755000,,, 281 | 2024,Cruz,Oneil,Pirates,SS,755000,,, 282 | 2024,Delay,Jason,Pirates,C,755000,,, 283 | 2024,Falter,Bailey,Pirates,LHP,755000,,, 284 | 2024,Hernandez,Jose,Pirates,LHP,755000,,, 285 | 2024,Holderman,Colin,Pirates,RHP,755000,,, 286 | 2024,Moreta,Dauri,Pirates,RHP,755000,,, 287 | 2024,Suwinski,Jack,Pirates,OF,755000,,, 288 | 2024,Banks,Tanner,White Sox,LHP,755050,,, 289 | 2024,Rortvedt,Ben,Rays,C,755400,,, 290 | 2024,Gorman,Nolan,Cardinals,2B,755550,,, 291 | 2024,Lowe,Josh,Rays,OF,755700,,, 292 | 2024,Jung,Josh,Rangers,3B,756000,,, 293 | 2024,Henderson,Gunnar,Orioles,SS,756200,,, 294 | 2024,Megill,Trevor,Brewers,RHP,756600,,, 295 | 2024,Kremer,Dean,Orioles,RHP,756600,,, 296 | 2024,Zavala,Seby,Mariners,C,756700,,, 297 | 2024,Pallante,Andre,Cardinals,RHP,756900,,, 298 | 2024,Sheets,Gavin,White Sox,INF,756950,,, 299 | 2024,Massey,Michael,Royals,2B,757000,,, 300 | 2024,Donovan,Brendan,Cardinals,INF,757200,,, 301 | 2024,Nelson,Kyle,Diamondbacks,LHP,757300,,, 302 | 2024,Walls,Taylor,Rays,INF,757300,,, 303 | 2024,Gray,Josiah,Nationals,RHP,757400,,, 304 | 2024,Kwan,Steven,Guardians,OF,757600,,, 305 | 2024,Brash,Matt,Mariners,RHP,757600,,, 306 | 2024,Clement,Ernie,Blue Jays,2B,757700,,, 307 | 2024,Siri,Jose,Rays,OF,757800,,, 308 | 2024,Isbel,Kyle,Royals,OF,758250,,, 309 | 2024,Holton,Tyler,Tigers,LHP,758300,,, 310 | 2024,Ryan,Joe,Twins,RHP,758850,,, 311 | 2024,Fortes,Nick,Marlins,C,759000,,, 312 | 2024,Lambert,Jimmy,White Sox,RHP,759250,,, 313 | 2024,O'Hoppe,Logan,Angels,C,760000,,, 314 | 2024,Soriano,Jose,Angels,RHP,760000,,, 315 | 2024,Kelenic,Jarred,Braves,OF,760000,,, 316 | 2024,Lee,Dylan,Braves,LHP,760000,,, 317 | 2024,Grove,Michael,Dodgers,RHP,760000,,, 318 | 2024,Burger,Jake,Marlins,3B,760000,,, 319 | 2024,Casas,Triston,Red Sox,1B,760000,,, 320 | 2024,Crawford,Kutter,Red Sox,RHP,760000,,, 321 | 2024,Dalbec,Bobby,Red Sox,INF,760000,,, 322 | 2024,Duran,Jarren,Red Sox,OF,760000,,, 323 | 2024,Winckowski,Josh,Red Sox,RHP,760000,,, 324 | 2024,Wong,Connor,Red Sox,C,760000,,, 325 | 2024,Diaz,Alexis,Reds,RHP,760000,,, 326 | 2024,Gibaut,Ian,Reds,RHP,760000,,, 327 | 2024,Lodolo,Nick,Reds,LHP,760000,,, 328 | 2024,Moll,Sam,Reds,LHP,760000,,, 329 | 2024,Gilbreath,Lucas,Rockies,LHP,760000,,, 330 | 2024,Moreno,Gabriel,Diamondbacks,C,760100,,, 331 | 2024,Rutschman,Adley,Orioles,C,760300,,, 332 | 2024,Henry,Tommy,Diamondbacks,LHP,760500,,, 333 | 2024,Pache,Cristian,Phillies,OF,760500,,, 334 | 2024,Lange,Alex,Tigers,RHP,760600,,, 335 | 2024,Vest,Will,Tigers,RHP,760700,,, 336 | 2024,Nootbaar,Lars,Cardinals,OF,761000,,, 337 | 2024,Cabrera,Edward,Marlins,RHP,761000,,, 338 | 2024,Brogdon,Connor,Phillies,RHP,761000,,, 339 | 2024,Carpenter,Kerry,Tigers,OF,761000,,, 340 | 2024,Jax,Griffin,Twins,RHP,761750,,, 341 | 2024,Ober,Bailey,Twins,RHP,761850,,, 342 | 2024,Cuas,Jose,Cubs,RHP,762000,,, 343 | 2024,Alvarez,Francisco,Mets,C,762500,,, 344 | 2024,Garrett,Braxton,Marlins,LHP,764000,,, 345 | 2024,Reyes,Pablo,Red Sox,INF,764000,,, 346 | 2024,Nelson,Ryne,Diamondbacks,RHP,764300,,, 347 | 2024,McKinstry,Zach,Tigers,INF,764400,,, 348 | 2024,Bielak,Brandon,Astros,RHP,765000,,, 349 | 2024,Oviedo,Johan,Pirates,RHP,765000,,, 350 | 2024,Torkelson,Spencer,Tigers,1B,765700,,, 351 | 2024,McCarthy,Jake,Diamondbacks,OF,766000,,, 352 | 2024,Vierling,Matt,Tigers,OF,766000,,, 353 | 2024,Ibanez,Andy,Tigers,INF,766100,,, 354 | 2024,Megill,Tylor,Mets,RHP,766250,,, 355 | 2024,Foley,Jason,Tigers,RHP,766300,,, 356 | 2024,Greene,Riley,Tigers,OF,766300,,, 357 | 2024,White,Mitch,Blue Jays,RHP,766400,,, 358 | 2024,Marsh,Brandon,Phillies,OF,766500,,, 359 | 2024,Peraza,Oswald,Yankees,SS,766600,,, 360 | 2024,Contreras,William,Brewers,C,766900,,, 361 | 2024,Morel,Christopher,Cubs,3B,767000,,, 362 | 2024,Meyers,Jake,Astros,OF,767300,,, 363 | 2024,France,J.P.,Astros,RHP,767600,,, 364 | 2024,De La Cruz,Bryan,Marlins,OF,768000,,, 365 | 2024,Stott,Bryson,Phillies,2B,768000,,, 366 | 2024,Ramirez,Yohan,Mets,RHP,768750,,, 367 | 2024,Diaz,Yainer,Astros,C,768900,,, 368 | 2024,Thomas,Alek,Diamondbacks,OF,769500,,, 369 | 2024,Adell,Jo,Angels,OF,770000,,, 370 | 2024,Detmers,Reid,Angels,LHP,770000,,, 371 | 2024,Moniak,Mickey,Angels,OF,770000,,, 372 | 2024,Thaiss,Matt,Angels,C,770000,,, 373 | 2024,Outman,James,Dodgers,OF,770000,,, 374 | 2024,Bart,Joey,Giants,C,770000,,, 375 | 2024,Doval,Camilo,Giants,RHP,770000,,, 376 | 2024,Bender,Anthony,Marlins,RHP,770000,,, 377 | 2024,Houck,Tanner,Red Sox,RHP,770000,,, 378 | 2024,Reid-Foley,Sean,Mets,RHP,772750,,, 379 | 2024,Weems,Jordan,Nationals,RHP,773500,,, 380 | 2024,Brown,Hunter,Astros,RHP,774500,,, 381 | 2024,Vieira,Thyago,Brewers,RHP,777500,,, 382 | 2024,Manoah,Alek,Blue Jays,RHP,782500,,, 383 | 2024,Cabrera,Oswaldo,Yankees,OF,783000,,, 384 | 2024,Pena,Jeremy,Astros,SS,783500,,, 385 | 2024,Perdomo,Geraldo,Diamondbacks,SS,786000,,, 386 | 2024,Scott,Tayler,Astros,RHP,790000,,, 387 | 2024,Alcala,Jorge,Twins,RHP,790000,,, 388 | 2024,Raleigh,Cal,Mariners,C,795000,,, 389 | 2024,Kirby,George,Mariners,RHP,798600,,, 390 | 2024,Garrett,Stone,Nationals,OF,798600,,, 391 | 2024,Adams,Austin,Athletics,RHP,800000,,, 392 | 2024,Stratton,Hunter,Pirates,RHP,800000,,, 393 | 2024,Shaw,Bryan,White Sox,RHP,800000,,, 394 | 2024,Burdi,Nick,Yankees,RHP,800000,,, 395 | 2024,Pearson,Nate,Blue Jays,RHP,800000,,, 396 | 2024,Perkins,Blake,Brewers,OF,800000,,, 397 | 2024,Crochet,Garrett,White Sox,LHP,800000,,, 398 | 2024,Volpe,Anthony,Yankees,SS,810100,,, 399 | 2024,Akin,Keegan,Orioles,LHP,825000,,, 400 | 2024,Ryan,Ryder,Pirates,RHP,830000,,, 401 | 2024,Antone,Tejay,Reds,RHP,830000,,, 402 | 2024,Mize,Casey,Tigers,RHP,830000,,, 403 | 2024,Quijada,Jose,Angels,LHP,840000,,, 404 | 2024,Ahmed,Nick,Giants,SS,850000,,, 405 | 2024,McFarland,T.J.,Athletics,LHP,850000,,, 406 | 2024,Singleton,Jonathan,Astros,1B,850000,,, 407 | 2024,Wade,Tyler,Padres,3B,850000,,, 408 | 2024,Covey,Dylan,Phillies,RHP,850000,,, 409 | 2024,Stubbs,Garrett,Phillies,C,850000,,, 410 | 2024,Fleming,Josh,Pirates,LHP,850000,,, 411 | 2024,Romero,JoJo,Cardinals,LHP,860000,,, 412 | 2024,Gonzalez,Victor,Yankees,LHP,860000,,, 413 | 2024,Bazardo,Eduard,Mariners,RHP,870600,,, 414 | 2024,Sano,Miguel,Angels,3B,875000,,, 415 | 2024,Haggerty,Sam,Mariners,2B,900000,,, 416 | 2024,Gordon,Nick,Marlins,OF,900000,,, 417 | 2024,Stewart,Brock,Twins,RHP,900000,,, 418 | 2024,Hamilton,Ian,Yankees,RHP,923050,,, 419 | 2024,Suarez,Jose,Angels,LHP,925000,,, 420 | 2024,Mantiply,Joe,Diamondbacks,LHP,925000,,, 421 | 2024,Staumont,Josh,Twins,RHP,950000,,, 422 | 2024,Newcomb,Sean,Athletics,LHP,1000000,,, 423 | 2024,Strider,Spencer,Braves,RHP,1000000,6 (2023-28),75000000,12500000 424 | 2024,Treinen,Blake,Dodgers,RHP,1000000,,, 425 | 2024,Vesia,Alex,Dodgers,LHP,1000000,,, 426 | 2024,Smith,Burch,Marlins,RHP,1000000,,, 427 | 2024,Tonkin,Michael,Mets,RHP,1000000,,, 428 | 2024,Bautista,Felix,Orioles,RHP,1000000,,, 429 | 2024,Kemp,Tony,Orioles,OF,1000000,,, 430 | 2024,Webb,Jacob,Orioles,RHP,1000000,,, 431 | 2024,Profar,Jurickson,Padres,OF,1000000,,, 432 | 2024,Devenski,Chris,Rays,RHP,1000000,,, 433 | 2024,Cave,Jake,Rockies,OF,1000000,,, 434 | 2024,Pillar,Kevin,White Sox,OF,1000000,,, 435 | 2024,Hernandez,Carlos,Royals,RHP,1012500,,, 436 | 2024,Wilson,Bryse,Brewers,RHP,1025000,,, 437 | 2024,Sborz,Josh,Rangers,RHP,1025000,,, 438 | 2024,Burke,Brock,Rangers,LHP,1035000,,, 439 | 2024,Brentz,Jake,Royals,LHP,1050000,2 (2023-24),1900000,950000 440 | 2024,Okert,Steven,Twins,LHP,1062500,,, 441 | 2024,Sandlin,Nick,Guardians,RHP,1075000,,, 442 | 2024,Guillorme,Luis,Braves,INF,1100000,,, 443 | 2024,Vargas,Ildemaro,Nationals,INF,1100000,,, 444 | 2024,Taylor,Josh,Royals,LHP,1100000,,, 445 | 2024,De Los Santos,Enyel,Padres,RHP,1160000,,, 446 | 2024,Young,Alex,Reds,LHP,1160000,,, 447 | 2024,Hentges,Sam,Guardians,LHP,1162500,,, 448 | 2024,Bello,Brayan,Red Sox,RHP,1166667,6 (2024-29),55000000,9166667 449 | 2024,Merryweather,Julian,Cubs,RHP,1175000,,, 450 | 2024,Schreiber,John,Royals,RHP,1175000,,, 451 | 2024,Beede,Tyler,Guardians,RHP,1200000,,, 452 | 2024,Waguespack,Jacob,Rays,RHP,1200000,,, 453 | 2024,Thornton,Trent,Mariners,RHP,1200000,,, 454 | 2024,Perez,Cionel,Orioles,LHP,1200000,,, 455 | 2024,Ginkel,Kevin,Diamondbacks,RHP,1225000,,, 456 | 2024,Lux,Gavin,Dodgers,2B,1225000,,, 457 | 2024,Topa,Justin,Twins,RHP,1225000,,, 458 | 2024,Hernandez,Jonathan,Rangers,RHP,1245000,,, 459 | 2024,Walsh,Jared,Rangers,1B,1250000,,, 460 | 2024,Clarke,Taylor,Brewers,RHP,1250000,,, 461 | 2024,Voth,Austin,Mariners,RHP,1250000,,, 462 | 2024,Anderson,Chase,Red Sox,RHP,1250000,,, 463 | 2024,Lambert,Peter,Rockies,RHP,1250000,,, 464 | 2024,Toro,Abraham,Athletics,INF,1275000,,, 465 | 2024,Chargois,JT,Marlins,RHP,1285000,,, 466 | 2024,Kinley,Tyler,Rockies,RHP,1300000,,, 467 | 2024,Jackson,Jay,Twins,RHP,1300000,,, 468 | 2024,Bauers,Jake,Brewers,1B,1350000,,, 469 | 2024,Thompson,Ryan,Diamondbacks,RHP,1350000,,, 470 | 2024,Olivares,Edward,Pirates,OF,1350000,,, 471 | 2024,Kirilloff,Alex,Twins,INF,1350000,,, 472 | 2024,Stewart,DJ,Mets,OF,1380000,,, 473 | 2024,Law,Derek,Nationals,RHP,1500000,,, 474 | 2024,Wilson,Justin,Reds,LHP,1500000,,, 475 | 2024,Leone,Dominic,White Sox,RHP,1500000,,, 476 | 2024,Gott,Trevor,Athletics,RHP,1500000,,, 477 | 2024,Ross,Joe,Brewers,RHP,1500000,,, 478 | 2024,Leiter Jr.,Mark,Cubs,RHP,1500000,,, 479 | 2024,Grichuk,Randal,Diamondbacks,OF,1500000,,, 480 | 2024,Rainey,Tanner,Nationals,RHP,1500000,,, 481 | 2024,Tate,Dillon,Orioles,RHP,1500000,,, 482 | 2024,Rosario,Amed,Rays,INF,1500000,,, 483 | 2024,McGuire,Reese,Red Sox,C,1500000,,, 484 | 2024,Hudson,Dakota,Rockies,RHP,1500000,,, 485 | 2024,Stallings,Jacob,Rockies,C,1500000,,, 486 | 2024,Tovar,Ezequiel,Rockies,SS,1500000,7 (2024-30),63500000,9071428 487 | 2024,Urshela,Gio,Tigers,3B,1500000,,, 488 | 2024,Trivino,Lou,Yankees,RHP,1500000,,, 489 | 2024,Cabrera,Genesis,Blue Jays,LHP,1512500,,, 490 | 2024,Rogers,Trevor,Marlins,LHP,1530000,,, 491 | 2024,Anderson,Nick,Royals,RHP,1575000,,, 492 | 2024,McKenzie,Triston,Guardians,RHP,1600000,,, 493 | 2024,Stephan,Trevor,Guardians,RHP,1600000,4 (2023-26),10000000,2500000 494 | 2024,Borucki,Ryan,Pirates,LHP,1600000,,, 495 | 2024,Cimber,Adam,Angels,RHP,1650000,,, 496 | 2024,Payamps,Joel,Brewers,RHP,1650000,,, 497 | 2024,Beeks,Jalen,Rockies,LHP,1675000,,, 498 | 2024,Andujar,Miguel,Athletics,OF,1700000,,, 499 | 2024,Sosa,Edmundo,Phillies,INF,1700000,,, 500 | 2024,Jankowski,Travis,Rangers,OF,1700000,,, 501 | 2024,Rogers,Jake,Tigers,C,1700000,,, 502 | 2024,Cooper,Garrett,Cubs,1B,1750000,,, 503 | 2024,Urena,Jose,Rangers,RHP,1750000,,, 504 | 2024,Cisnero,Jose,Angels,RHP,1750000,,, 505 | 2024,Abreu,Bryan,Astros,RHP,1750000,,, 506 | 2024,DeJong,Paul,White Sox,SS,1750000,,, 507 | 2024,Flexen,Chris,White Sox,RHP,1750000,,, 508 | 2024,Puk,A.J.,Marlins,LHP,1800000,,, 509 | 2024,Wright,Kyle,Royals,RHP,1800000,,, 510 | 2024,Hill,Tim,White Sox,LHP,1800000,,, 511 | 2024,Madrigal,Nick,Cubs,INF,1810000,,, 512 | 2024,Knizner,Andrew,Rangers,C,1825000,,, 513 | 2024,Littell,Zack,Rays,RHP,1850000,,, 514 | 2024,Refsnyder,Rob,Red Sox,OF,1850000,,, 515 | 2024,Rasmussen,Drew,Rays,RHP,1862500,,, 516 | 2024,Garcia,Luis,Astros,RHP,1875000,,, 517 | 2024,Matzek,Tyler,Braves,LHP,1900000,,, 518 | 2024,Almonte,Yency,Cubs,RHP,1900000,,, 519 | 2024,Karinchak,James,Guardians,RHP,1900000,,, 520 | 2024,Tauchman,Michael,Cubs,OF,1950000,,, 521 | 2024,Garcia Jr.,Luis,Nationals,2B,1950000,,, 522 | 2024,Alexander,Tyler,Rays,LHP,1950000,,, 523 | 2024,Wells,Tyler,Orioles,RHP,1962500,,, 524 | 2024,Carrasco,Carlos,Guardians,RHP,2000000,,, 525 | 2024,Barnes,Matt,Nationals,RHP,2000000,,, 526 | 2024,Winker,Jesse,Nationals,OF,2000000,,, 527 | 2024,Vogelbach,Daniel,Blue Jays,DH,2000000,,, 528 | 2024,Arcia,Orlando,Braves,SS,2000000,3 (2023-25),7300000,2433333 529 | 2024,Crawford,Brandon,Cardinals,SS,2000000,,, 530 | 2024,Hudson,Daniel,Dodgers,RHP,2000000,,, 531 | 2024,Lopez,Jorge,Mets,RHP,2000000,,, 532 | 2024,Wendle,Joey,Mets,INF,2000000,,, 533 | 2024,Senzel,Nick,Nationals,3B,2000000,,, 534 | 2024,Irvin,Cole,Orioles,LHP,2000000,,, 535 | 2024,Turnbull,Spencer,Phillies,RHP,2000000,,, 536 | 2024,Hendriks,Liam,Red Sox,RHP,2000000,2 (2024-25),10000000,5000000 537 | 2024,Rodriguez,Joely,Red Sox,LHP,2000000,,, 538 | 2024,Frazier,Adam,Royals,2B,2000000,,, 539 | 2024,Hampson,Garrett,Royals,2B,2000000,,, 540 | 2024,Weaver,Luke,Yankees,RHP,2000000,,, 541 | 2024,Taylor,Tyrone,Mets,OF,2025000,,, 542 | 2024,Schmidt,Clarke,Yankees,RHP,2025000,,, 543 | 2024,Milner,Hoby,Brewers,LHP,2050000,,, 544 | 2024,Bethancourt,Christian,Marlins,C,2050000,,, 545 | 2024,Armstrong,Shawn,Rays,RHP,2050000,,, 546 | 2024,Sanchez,Jesus,Marlins,OF,2100000,,, 547 | 2024,Urias,Ramon,Orioles,3B,2100000,,, 548 | 2024,Alzolay,Adbert,Cubs,RHP,2110000,,, 549 | 2024,Joe,Connor,Pirates,OF,2125000,,, 550 | 2024,May,Dustin,Dodgers,RHP,2135000,,, 551 | 2024,Richards,Trevor,Blue Jays,RHP,2150000,,, 552 | 2024,Peterson,David,Mets,LHP,2150000,,, 553 | 2024,Fraley,Jake,Reds,OF,2150000,,, 554 | 2024,Higashioka,Kyle,Padres,C,2180000,,, 555 | 2024,Munoz,Andres,Mariners,RHP,2187500,4 (2022-25),7500000,1875000 556 | 2024,Hoffman,Jeff,Phillies,RHP,2200000,,, 557 | 2024,Smith,Drew,Mets,RHP,2225000,,, 558 | 2024,Alexander,Scott,Athletics,LHP,2250000,,, 559 | 2024,Chourio,Jackson,Brewers,OF,2250000,(8 (2024-31),82000000,10250000 560 | 2024,Floro,Dylan,Nationals,RHP,2250000,,, 561 | 2024,Farmer,Buck,Reds,RHP,2250000,,, 562 | 2024,Kittredge,Andrew,Cardinals,RHP,2262500,,, 563 | 2024,Brubaker,JT,Pirates,RHP,2275000,,, 564 | 2024,Coulombe,Danny,Orioles,LHP,2300000,,, 565 | 2024,Harvey,Hunter,Nationals,RHP,2325000,,, 566 | 2024,Carlson,Dylan,Cardinals,OF,2350000,,, 567 | 2024,Bubic,Kris,Royals,LHP,2350000,,, 568 | 2024,Poche,Colin,Rays,LHP,2375000,,, 569 | 2024,Ferguson,Caleb,Yankees,LHP,2400000,,, 570 | 2024,Jeffers,Ryan,Twins,C,2425000,,, 571 | 2024,Franco,Wander,Rays,SS,2454545,11 (2022-32),182000000,16545454.5455 572 | 2024,Davis,J.D.,Athletics,3B,2500000,,, 573 | 2024,Woodruff,Brandon,Brewers,RHP,2500000,2 (2024-25),22000000,11000000 574 | 2024,Gallo,Joey,Nationals,OF,2500000,,, 575 | 2024,Grandal,Yasmani,Pirates,C,2500000,,, 576 | 2024,Suter,Brent,Reds,LHP,2500000,,, 577 | 2024,Loaisiga,Jonathan,Yankees,RHP,2500000,,, 578 | 2024,Stephenson,Tyler,Reds,C,2525000,,, 579 | 2024,Paddack,Chris,Twins,RHP,2525000,3 (2023-25),12525000,4175000 580 | 2024,Taveras,Leody,Rangers,OF,2550000,,, 581 | 2024,Canning,Griffin,Angels,RHP,2600000,,, 582 | 2024,Brown,Seth,Athletics,OF,2600000,,, 583 | 2024,Chisholm Jr.,Jazz,Marlins,OF,2625000,,, 584 | 2024,Robles,Victor,Nationals,OF,2650000,,, 585 | 2024,Skubal,Tarik,Tigers,LHP,2650000,,, 586 | 2024,Graterol,Brusdar,Dodgers,RHP,2700000,,, 587 | 2024,Mateo,Jorge,Orioles,2B,2700000,,, 588 | 2024,Adam,Jason,Rays,RHP,2700000,,, 589 | 2024,Wisdom,Patrick,Cubs,OF,2725000,,, 590 | 2024,Espinal,Santiago,Reds,INF,2725000,,, 591 | 2024,Trevino,Jose,Yankees,C,2730000,,, 592 | 2024,Swanson,Erik,Blue Jays,RHP,2750000,,, 593 | 2024,Kirk,Alejandro,Blue Jays,C,2800000,,, 594 | 2024,Keith,Colt,Tigers,2B,2833333,6 (2024-29),28642500,4773750 595 | 2024,McCormick,Chas,Astros,OF,2850000,,, 596 | 2024,Sims,Lucas,Reds,RHP,2850000,,, 597 | 2024,Clase,Emmanuel,Guardians,RHP,2900000,,, 598 | 2024,Duvall,Adam,Braves,OF,3000000,,, 599 | 2024,Sanchez,Gary,Brewers,C,3000000,,, 600 | 2024,McGough,Scott,Diamondbacks,RHP,3000000,2 (2023-24),6250000,3125000 601 | 2024,Maile,Luke,Reds,C,3000000,,, 602 | 2024,Miller,Shelby,Tigers,RHP,3000000,,, 603 | 2024,Kopech,Michael,White Sox,RHP,3000000,,, 604 | 2024,Soroka,Michael,White Sox,RHP,3000000,,, 605 | 2024,Heim,Jonah,Rangers,C,3050000,,, 606 | 2024,Rojas,Josh,Mariners,3B,3100000,,, 607 | 2024,Witt Jr.,Bobby,Royals,SS,3111111,11 (2024-34),288777777,26252525 608 | 2024,Moore,Dylan,Mariners,OF,3133333,,, 609 | 2024,King,Michael,Padres,RHP,3150000,,, 610 | 2024,Gomber,Austin,Rockies,LHP,3150000,,, 611 | 2024,Rogers,Tyler,Giants,RHP,3200000,,, 612 | 2024,Tellez,Rowdy,Pirates,1B,3200000,,, 613 | 2024,Rodgers,Brendan,Rockies,2B,3200000,,, 614 | 2024,Thielbar,Caleb,Twins,LHP,3225000,,, 615 | 2024,Matsui,Yuki,Padres,LHP,3250000,5 (2024-28),28000000,5600000 616 | 2024,Vaughn,Andrew,White Sox,1B,3250000,,, 617 | 2024,Castro,Willi,Twins,OF,3300000,,, 618 | 2024,Means,John,Orioles,LHP,3325000,,, 619 | 2024,Dunning,Dane,Rangers,RHP,3325000,,, 620 | 2024,Greene,Hunter,Reds,RHP,3333333,6 (2023-28),53000000,8833333 621 | 2024,Peralta,Wandy,Padres,LHP,3350000,4 (2024-27),16500000,4125000 622 | 2024,Paredes,Isaac,Rays,3B,3400000,,, 623 | 2024,Blackburn,Paul,Athletics,RHP,3450000,,, 624 | 2024,Dubon,Mauricio,Astros,2B,3500000,,, 625 | 2024,Rea,Colin,Brewers,RHP,3500000,,, 626 | 2024,Barnes,Austin,Dodgers,C,3500000,,, 627 | 2024,Wade,LaMonte,Giants,1B,3500000,,, 628 | 2024,O'Hearn,Ryan,Orioles,1B,3500000,,, 629 | 2024,Whitlock,Garrett,Red Sox,RHP,3500000,4 (2023-26),18750000,4687500 630 | 2024,Stratton,Chris,Royals,RHP,3500000,2 (2024-25),8000000,4000000 631 | 2024,Kelly,Carson,Tigers,C,3500000,,, 632 | 2024,Mayza,Tim,Blue Jays,LHP,3590000,,, 633 | 2024,McClanahan,Shane,Rays,LHP,3600000,,, 634 | 2024,Carroll,Corbin,Diamondbacks,OF,3625000,8 (2023-31),111000000,13875000 635 | 2024,Berti,Jon,Yankees,INF,3625000,,, 636 | 2024,Urquidy,Jose,Astros,RHP,3750000,,, 637 | 2024,Helsley,Ryan,Cardinals,RHP,3800000,,, 638 | 2024,Ramirez,Harold,Rays,OF,3800000,,, 639 | 2024,India,Jonathan,Reds,2B,3800000,2 (2024-25),8800000,4400000 640 | 2024,Fairbanks,Pete,Rays,RHP,3816667,,, 641 | 2024,Yarbrough,Ryan,Dodgers,LHP,3900000,,, 642 | 2024,Cortes,Nestor,Yankees,LHP,3950000,,, 643 | 2024,Lopez,Reynaldo,Braves,RHP,4000000,3 (2024-26),30000000,10000000 644 | 2024,Junis,Jakob,Brewers,RHP,4000000,,, 645 | 2024,Steele,Justin,Cubs,LHP,4000000,,, 646 | 2024,Hernandez,Kike,Dodgers,INF,4000000,,, 647 | 2024,Phillips,Evan,Dodgers,RHP,4000000,,, 648 | 2024,Murphy,Tom,Giants,C,4000000,2 (2024-25),8250000,4125000 649 | 2024,Slater,Austin,Giants,OF,4000000,,, 650 | 2024,Hedges,Austin,Guardians,C,4000000,,, 651 | 2024,Stanek,Ryne,Mariners,RHP,4000000,,, 652 | 2024,Diekman,Jake,Mets,LHP,4000000,,, 653 | 2024,Rosario,Eddie,Nationals,OF,4000000,,, 654 | 2024,Bohm,Alec,Phillies,3B,4000000,,, 655 | 2024,Taylor,Michael A.,Pirates,OF,4000000,,, 656 | 2024,Brebbia,John,White Sox,RHP,4000000,,, 657 | 2024,Maldonado,Martin,White Sox,C,4000000,,, 658 | 2024,Gilbert,Logan,Mariners,RHP,4050000,,, 659 | 2024,Mountcastle,Ryan,Orioles,DH,4137000,,, 660 | 2024,Biggio,Cavan,Blue Jays,2B,4210000,,, 661 | 2024,Garcia,Luis,Angels,RHP,4250000,,, 662 | 2024,Dominguez,Seranthony,Phillies,RHP,4250000,,, 663 | 2024,Chafin,Andrew,Tigers,LHP,4250000,,, 664 | 2024,Lopez,Nicky,White Sox,2B,4300000,,, 665 | 2024,Rengifo,Luis,Angels,2B,4400000,,, 666 | 2024,Brasier,Ryan,Dodgers,RHP,4500000,2 (2024-25),9000000,4500000 667 | 2024,Ottavino,Adam,Mets,RHP,4500000,2 (2023-24),14500000,7250000 668 | 2024,Lorenzen,Michael,Rangers,RHP,4500000,,, 669 | 2024,Yates,Kirby,Rangers,RHP,4500000,,, 670 | 2024,Bednar,David,Pirates,RHP,4510000,,, 671 | 2024,Estrada,Thairo,Giants,2B,4700000,,, 672 | 2024,Garcia,Adolis,Rangers,OF,4750000,2 (2024-25),14000000,7000000 673 | 2024,Ward,Taylor,Angels,OF,4800000,,, 674 | 2024,Singer,Brady,Royals,RHP,4850000,,, 675 | 2024,Civale,Aaron,Rays,RHP,4900000,,, 676 | 2024,Harris II,Mike,Braves,OF,5000000,8 (2023-30),72000000,9000000 677 | 2024,Middleton,Keynan,Cardinals,RHP,5000000,,, 678 | 2024,Castro,Miguel,Diamondbacks,RHP,5000000,,, 679 | 2024,Peterson,Jace,Diamondbacks,INF,5000000,2 (2023-24),9500000,4750000 680 | 2024,Kershaw,Clayton,Dodgers,LHP,5000000,2 (2024-25),10000000,5000000 681 | 2024,Urias,Luis,Mariners,2B,5000000,,, 682 | 2024,Anderson,Tim,Marlins,SS,5000000,,, 683 | 2024,Soto,Gregory,Phillies,LHP,5000000,,, 684 | 2024,McCutchen,Andrew,Pirates,OF,5000000,,, 685 | 2024,Smith,Will,Royals,LHP,5000000,,, 686 | 2024,Sandoval,Patrick,Angels,LHP,5025000,,, 687 | 2024,Houser,Adrian,Mets,RHP,5050000,,, 688 | 2024,Suarez,Ranger,Phillies,LHP,5050000,,, 689 | 2024,Finnegan,Kyle,Nationals,RHP,5100000,,, 690 | 2024,Laureano,Ramon,Guardians,OF,5150000,,, 691 | 2024,Jansen,Danny,Blue Jays,C,5200000,,, 692 | 2024,Springs,Jeffrey,Rays,LHP,5250000,4 (2023-26),31000000,7750000 693 | 2024,Santana,Carlos,Twins,1B,5250000,,, 694 | 2024,Gonsolin,Anthony,Dodgers,RHP,5400000,,, 695 | 2024,Keller,Mitch,Pirates,RHP,5442500,5 (2024-28),77000000,15400000 696 | 2024,Thomas,Lane,Nationals,OF,5450000,,, 697 | 2024,Bummer,Aaron,Braves,LHP,5500000,5 (2020-24),16000000,3200000 698 | 2024,Luzardo,Jesus,Marlins,LHP,5500000,,, 699 | 2024,Mahle,Tyler,Rangers,RHP,5500000,2 (2024-25),22000000,11000000 700 | 2024,Renfroe,Hunter,Royals,OF,5500000,2 (2024-25),13000000,6500000 701 | 2024,Grisham,Trent,Yankees,OF,5500000,,, 702 | 2024,Gimenez,Andres,Guardians,2B,5571429,7 (2023-29),106500000,15214286 703 | 2024,Varsho,Daulton,Blue Jays,OF,5650000,,, 704 | 2024,Scott,Tanner,Marlins,LHP,5700000,,, 705 | 2024,Peralta,Freddy,Brewers,RHP,5734960,5 (2020-24),15500000,3100000 706 | 2024,Gallegos,Giovanny,Cardinals,RHP,5750000,,, 707 | 2024,Rojas,Miguel,Dodgers,SS,5750000,,, 708 | 2024,Kahnle,Tommy,Yankees,RHP,5750000,3 (2022-24),14500000,4833333 709 | 2024,O'Neill,Tyler,Red Sox,OF,5850000,,, 710 | 2024,Caratini,Victor,Astros,C,6000000,2 (2024-25),12000000,6000000 711 | 2024,Garcia,Yimi,Blue Jays,RHP,6000000,,, 712 | 2024,Gomes,Yan,Cubs,C,6000000,,, 713 | 2024,Diaz,Elias,Rockies,C,6000000,3 (2022-24),14500000,4833333.3333 714 | 2024,Holmes,Clay,Yankees,RHP,6000000,,, 715 | 2024,Farmer,Kyle,Twins,2B,6050000,,, 716 | 2024,Minter,A.J.,Braves,LHP,6220000,,, 717 | 2024,Carpenter,Matt,Cardinals,DH,6240000,2 (2023-24),12000000,6000000 718 | 2024,Leclerc,Jose,Rangers,RHP,6250000,,, 719 | 2024,Maton,Phil,Rays,RHP,6250000,,, 720 | 2024,Hays,Austin,Orioles,OF,6300000,,, 721 | 2024,Mullins,Cedric,Orioles,OF,6325000,,, 722 | 2024,Ruiz,Keibert,Nationals,C,6375000,8 (2023-30),50000000,6250000 723 | 2024,Flores,Wilmer,Giants,SS,6500000,,, 724 | 2024,Hicks,Jordan,Giants,RHP,6500000,4 (2024-27),44000000,11000000 725 | 2024,Jackson,Luke,Giants,RHP,6500000,2 (2023-24),11500000,5750000 726 | 2024,Raley,Brooks,Mets,LHP,6500000,,, 727 | 2024,Naylor,Josh,Guardians,1B,6550000,,, 728 | 2024,Quantrill,Cal,Rockies,RHP,6550000,,, 729 | 2024,Barlow,Scott,Guardians,RHP,6700000,,, 730 | 2024,Estevez,Carlos,Angels,RHP,6750000,2 (2023-24),13500000,6750000 731 | 2024,France,Ty,Mariners,1B,6775000,,, 732 | 2024,Albies,Ozzie,Braves,2B,7000000,7 (2019-25),35000000,5000000 733 | 2024,Johnson,Pierce,Braves,RHP,7000000,2 (2024-25),14250000,7125000 734 | 2024,Williams,Devin,Brewers,RHP,7000000,,, 735 | 2024,Edman,Tommy,Cardinals,SS,7000000,2 (2024-25),16500000,8250000 736 | 2024,Paxton,James,Dodgers,LHP,7000000,,, 737 | 2024,Narvaez,Omar,Mets,C,7000000,2 (2023-24),15000000,7500000 738 | 2024,Williams,Trevor,Nationals,RHP,7000000,2 (2023-24),13000000,6500000 739 | 2024,Merrifield,Whit,Phillies,INF,7000000,,, 740 | 2024,Hayes,Ke'Bryan,Pirates,3B,7000000,8 (2022-29),70000000,8750000 741 | 2024,Stassi,Max,White Sox,C,7000000,3 (2022-24),17500000,5833333.3333 742 | 2024,Cronenworth,Jake,Padres,1B,7285714,7 (2024-30),80000000,11428571 743 | 2024,Sewald,Paul,Diamondbacks,RHP,7350000,,, 744 | 2024,Javier,Cristian,Astros,RHP,7400000,5 (2023-27),64000000,12800000 745 | 2024,Kiner-Falefa,Isiah,Blue Jays,3B,7500000,2 (2024-25),15000000,7500000 746 | 2024,Strahm,Matt,Phillies,LHP,7500000,2 (2023-24),15000000,7500000 747 | 2024,Lowe,Nate,Rangers,1B,7500000,,, 748 | 2024,Pivetta,Nick,Red Sox,RHP,7500000,,, 749 | 2024,Fedde,Erick,White Sox,RHP,7500000,2 (2024-25),15000000,7500000 750 | 2024,Romano,Jordan,Blue Jays,RHP,7750000,,, 751 | 2024,Yastrzemski,Mike,Giants,OF,7900000,,, 752 | 2024,Graveman,Kendall,Astros,RHP,8000000,3 (2022-24),24000000,8000000 753 | 2024,Diaz,Aledmys,Athletics,INF,8000000,2 (2023-24),14500000,7250000 754 | 2024,d'Arnaud,Travis,Braves,C,8000000,,, 755 | 2024,Jimenez,Joe,Braves,RHP,8000000,3 (2024-26),26000000,8666667 756 | 2024,Kelly,Joe,Dodgers,RHP,8000000,,, 757 | 2024,Webb,Logan,Giants,RHP,8000000,5 (2024-28),90000000,18000000 758 | 2024,Cease,Dylan,Padres,RHP,8000000,,, 759 | 2024,Kim,Ha-Seong,Padres,SS,8000000,4 (2021-24),28000000,7000000 760 | 2024,Perez,Martin,Pirates,LHP,8000000,,, 761 | 2024,Diaz,Yandy,Rays,1B,8000000,3 (2023-25),24000000,8000000 762 | 2024,Pagan,Emilio,Reds,RHP,8000000,2 (2024-25),16000000,8000000 763 | 2024,Buehler,Walker,Dodgers,RHP,8025000,,, 764 | 2024,Arozarena,Randy,Rays,OF,8100000,,, 765 | 2024,Lee,Jung-Hoo,Giants,OF,8250000,6 (2024-29),113000000,18833333 766 | 2024,Lopez,Pablo,Twins,RHP,8250000,4 (2024-27),73500000,18375000 767 | 2024,Robertson,David,Rangers,RHP,8283253,,, 768 | 2024,Drury,Brandon,Angels,DH,8500000,2 (2023-24),17000000,8500000 769 | 2024,Wood,Alex,Athletics,LHP,8500000,,, 770 | 2024,Miley,Wade,Brewers,LHP,8500000,,, 771 | 2024,Kelly,Merrill,Diamondbacks,RHP,8500000,2 (2023-24),18000000,9000000 772 | 2024,Lyles,Jordan,Royals,RHP,8500000,2 (2023-24),17000000,8500000 773 | 2024,Verdugo,Alex,Yankees,OF,8700000,,, 774 | 2024,Lowe,Brandon,Rays,2B,8750000,6 (2019-24),24000000,4000000 775 | 2024,Moore,Matt,Angels,LHP,9000000,,, 776 | 2024,Murphy,Sean,Braves,C,9000000,6 (2023-28),73000000,12166667 777 | 2024,Neris,Hector,Cubs,RHP,9000000,,, 778 | 2024,Heyward,Jason,Dodgers,OF,9000000,,, 779 | 2024,Alvarado,Jose,Phillies,LHP,9025000,3 (2023-25),22000000,11000000 780 | 2024,Yamamoto,Yoshinobu,Dodgers,RHP,9166667,12 (2024-35),325000000,27083333 781 | 2024,Alcantara,Sandy,Marlins,RHP,9300000,5 (2022-26),56000000,11200000 782 | 2024,Imanaga,Shota,Cubs,LHP,9500000,4 (2024-27),53000000,13250000 783 | 2024,Pederson,Joc,Diamondbacks,OF,9500000,,, 784 | 2024,Muncy,Max,Dodgers,3B,9500000,2 (2024-25),24000000,12000000 785 | 2024,Martin,Chris,Red Sox,RHP,9500000,2 (2023-24),17500000,8750000 786 | 2024,Bard,Daniel,Rockies,RHP,9500000,,, 787 | 2024,Kikuchi,Yusei,Blue Jays,LHP,10000000,3 (2022-24),36000000,12000000 788 | 2024,Gray,Sonny,Cardinals,RHP,10000000,3 (2024-26),75000000,25000000 789 | 2024,Lynn,Lance,Cardinals,RHP,10000000,,, 790 | 2024,Gurriel Jr.,Lourdes,Diamondbacks,OF,10000000,3 (2024-26),42000000,14000000 791 | 2024,Cobb,Alex,Giants,RHP,10000000,,, 792 | 2024,Soler,Jorge,Giants,DH,10000000,3 (2024-26),42000000,14000000 793 | 2024,Suarez,Robert,Padres,RHP,10000000,5 (2023-27),46000000,9200000 794 | 2024,Marquez,German,Rockies,RHP,10000000,2 (2024-25),20000000,10000000 795 | 2024,Kepler,Max,Twins,OF,10000000,,, 796 | 2024,Margot,Manuel,Twins,OF,10000000,,, 797 | 2024,Vazquez,Christian,Twins,C,10000000,3 (2023-25),30000000,10000000 798 | 2024,Gallen,Zac,Diamondbacks,RHP,10011000,,, 799 | 2024,Hicks,Aaron,Angels,OF,10240000,7 (2019-25),70000000,10000000 800 | 2024,McNeil,Jeff,Mets,2B,10250000,4 (2023-26),50000000,12500000 801 | 2024,Reynolds,Bryan,Pirates,OF,10250000,8 (2023-30),106750000,13343750 802 | 2024,Green,Chad,Blue Jays,RHP,10500000,2 (2023-24),8500000,4250000 803 | 2024,Kiermaier,Kevin,Blue Jays,OF,10500000,,, 804 | 2024,Smyly,Drew,Cubs,LHP,10500000,2 (2023-24),19000000,9500000 805 | 2024,Garver,Mitch,Mariners,DH,10500000,2 (2024-25),24000000,12000000 806 | 2024,Polanco,Jorge,Mariners,2B,10500000,,, 807 | 2024,Bader,Harrison,Mets,OF,10500000,,, 808 | 2024,Chapman,Aroldis,Pirates,LHP,10500000,,, 809 | 2024,Arraez,Luis,Marlins,2B,10600000,,, 810 | 2024,Alvarez,Yordan,Astros,DH,10833333,6 (2023-28),115000000,19166667 811 | 2024,Walker,Christian,Diamondbacks,1B,10900000,,, 812 | 2024,Stephenson,Robert,Angels,RHP,11000000,3 (2024-26),33000000,11000000 813 | 2024,Suarez,Eugenio,Diamondbacks,3B,11000000,7 (2018-24),66000000,9428571.4286 814 | 2024,Crawford,J.P.,Mariners,SS,11000000,5 (2022-26),51000000,10200000 815 | 2024,Eflin,Zach,Rays,RHP,11000000,3 (2023-25),40000000,13333333 816 | 2024,Montero,Rafael,Astros,RHP,11500000,3 (2023-25),34500000,11500000 817 | 2024,Hoerner,Nico,Cubs,2B,11500000,3 (2024-26),35000000,11666667 818 | 2024,Canha,Mark,Tigers,OF,11500000,,, 819 | 2024,Santander,Anthony,Orioles,OF,11700000,,, 820 | 2024,Tatis Jr.,Fernando,Padres,OF,11714286,14 (2021-34),340000000,24285714.2857 821 | 2024,Tucker,Kyle,Astros,OF,12000000,,, 822 | 2024,Hoskins,Rhys,Brewers,1B,12000000,2 (2024-25),34000000,17000000 823 | 2024,Gibson,Kyle,Cardinals,RHP,12000000,,, 824 | 2024,Rogers,Taylor,Giants,LHP,12000000,3 (2023-25),33000000,11000000 825 | 2024,Garcia,Avisail,Marlins,OF,12000000,4 (2022-25),53000000,13250000 826 | 2024,Kimbrel,Craig,Orioles,RHP,12000000,,, 827 | 2024,McCann,James,Orioles,C,12000000,4 (2021-24),40600000,10150000 828 | 2024,Gonzales,Marco,Pirates,LHP,12000000,4 (2021-24),30000000,7500000 829 | 2024,McMahon,Ryan,Rockies,3B,12000000,6 (2022-27),70000000,11666667 830 | 2024,Senzatela,Antonio,Rockies,RHP,12000000,5 (2022-26),50500000,10100000 831 | 2024,DeSclafani,Anthony,Twins,RHP,12000000,3 (2022-24),36000000,12000000 832 | 2024,Bichette,Bo,Blue Jays,SS,12083333,3 (2023-25),33600000,11200000 833 | 2024,Valdez,Framber,Astros,LHP,12100000,,, 834 | 2024,Rodriguez,Julio,Mariners,OF,12185714,12 (2023-34),209300000,17441667 835 | 2024,Adames,Willy,Brewers,SS,12250000,,, 836 | 2024,Stripling,Ross,Athletics,RHP,12500000,2 (2023-24),25000000,12500000 837 | 2024,Matz,Steven,Cardinals,LHP,12500000,4 (2022-25),44000000,11000000 838 | 2024,Robert Jr.,Luis,White Sox,OF,12500000,6 (2020-25),50000000,8333333.3333 839 | 2024,Anderson,Tyler,Angels,LHP,13000000,3 (2023-25),39000000,13000000 840 | 2024,Turner,Justin,Blue Jays,DH,13000000,,, 841 | 2024,Taylor,Chris,Dodgers,OF,13000000,4 (2022-25),60000000,15000000 842 | 2024,Quintana,Jose,Mets,LHP,13000000,2 (2023-24),26000000,13000000 843 | 2024,Severino,Luis,Mets,RHP,13000000,,, 844 | 2024,Gray,Jon,Rangers,RHP,13000000,4 (2022-25),56000000,14000000 845 | 2024,Heaney,Andrew,Rangers,LHP,13000000,2 (2023-24),25000000,12500000 846 | 2024,Candelario,Jeimer,Reds,3B,13000000,3 (2024-26),45000000,15000000 847 | 2024,Blackmon,Charlie,Rockies,DH,13000000,,, 848 | 2024,Bieber,Shane,Guardians,RHP,13125000,,, 849 | 2024,Smith,Will,Dodgers,C,13550000,10 (2024-33),140000000, 850 | 2024,Marte,Ketel,Diamondbacks,2B,13600000,5 (2023-27),76000000,15200000 851 | 2024,Jimenez,Eloy,White Sox,DH,13833333,6 (2019-24),43000000,7166666.6667 852 | 2024,Pressly,Ryan,Astros,RHP,14000000,2 (2023-24),30000000,15000000 853 | 2024,Rodriguez,Eduardo,Diamondbacks,LHP,14000000,4 (2024-27),80000000,20000000 854 | 2024,Martinez,Nick,Reds,RHP,14000000,2 (2024-25),26000000,13000000 855 | 2024,Flaherty,Jack,Tigers,RHP,14000000,,, 856 | 2024,Maeda,Kenta,Tigers,RHP,14000000,2 (2024-25),24000000,12000000 857 | 2024,Torres,Gleyber,Yankees,2B,14200000,,, 858 | 2024,Manaea,Sean,Mets,LHP,14500000,2 (2024-25),28000000,14000000 859 | 2024,Fried,Max,Braves,LHP,15000000,,, 860 | 2024,Glasnow,Tyler,Dodgers,RHP,15000000,5 (2024-28),136562500,27312500 861 | 2024,Freeland,Kyle,Rockies,LHP,15000000,5 (2022-26),64500000,12900000 862 | 2024,Lugo,Seth,Royals,RHP,15000000,3 (2024-26),45000000,15000000 863 | 2024,LeMahieu,DJ,Yankees,3B,15000000,6 (2021-26),90000000,15000000 864 | 2024,Buxton,Byron,Twins,OF,15142857,7 (2022-28),100000000,14285714.2857 865 | 2024,Burnes,Corbin,Orioles,RHP,15637500,,, 866 | 2024,Senga,Kodai,Mets,RHP,15666667,5 (2023-27),75000000,15000000 867 | 2024,Iglesias,Raisel,Braves,RHP,16000000,4 (2022-25),58000000,14500000 868 | 2024,Sale,Chris,Braves,LHP,16000000,2 (2024-25),38000000,18000000 869 | 2024,Darvish,Yu,Padres,RHP,16000000,6 (2023-28),108000000,18000000 870 | 2024,Jansen,Kenley,Red Sox,RHP,16000000,2 (2023-24),32000000,16000000 871 | 2024,Montas,Frankie,Reds,RHP,16000000,,, 872 | 2024,Wacha,Michael,Royals,RHP,16000000,2 (2024-25),32000000,16000000 873 | 2024,Hendricks,Kyle,Cubs,RHP,16500000,,, 874 | 2024,Bell,Josh,Marlins,1B,16500000,2 (2023-24),33000000,16500000 875 | 2024,Acuna Jr.,Ronald,Braves,OF,17000000,8 (2019-26),100000000,12500000 876 | 2024,Ramirez,Jose,Guardians,3B,17000000,7 (2022-28),141000000,20142857.1429 877 | 2024,Haniger,Mitch,Mariners,OF,17000000,3 (2023-25),43500000,14500000 878 | 2024,Eovaldi,Nathan,Rangers,RHP,17000000,2 (2023-24),34000000,17000000 879 | 2024,Rizzo,Anthony,Yankees,1B,17000000,2 (2023-24),40000000,20000000 880 | 2024,Machado,Manny,Padres,3B,17090909,11 (2023-33),350000000,31818182 881 | 2024,Benintendi,Andrew,White Sox,OF,17100000,5 (2023-27),75000000,15000000 882 | 2024,Mikolas,Miles,Cardinals,RHP,17666667,3 (2023-25),55750000,18583333 883 | 2024,McCullers Jr.,Lance,Astros,RHP,17700000,5 (2022-26),85000000,17000000 884 | 2024,Berrios,Jose,Blue Jays,RHP,18000000,7 (2022-28),131000000,18714285.7143 885 | 2024,Ozuna,Marcell,Braves,DH,18000000,4 (2021-24),65000000,16250000 886 | 2024,Contreras,Willson,Cardinals,C,18000000,5 (2023-27),87500000,17500000 887 | 2024,Taillon,Jameson,Cubs,RHP,18000000,4 (2023-26),68000000,17000000 888 | 2024,Chapman,Matt,Giants,3B,18000000,3 (2024-26),54000000,18000000 889 | 2024,Conforto,Michael,Giants,OF,18000000,2 (2023-24),36000000,18000000 890 | 2024,Walker,Taijuan,Phillies,RHP,18000000,4 (2023-26),72000000,18000000 891 | 2024,Giolito,Lucas,Red Sox,RHP,18000000,2 (2024-25),38500000,19250000 892 | 2024,Diaz,Edwin,Mets,RHP,18256300,5 (2023-27),102000000,20400000 893 | 2024,Stroman,Marcus,Yankees,RHP,18500000,2 (2024-25),37000000,18500000 894 | 2024,Yoshida,Masataka,Red Sox,OF,18600000,5 (2023-27),90000000,18000000 895 | 2024,Hader,Josh,Astros,LHP,19000000,5 (2024-28),95000000,19000000 896 | 2024,Abreu,Jose,Astros,1B,19500000,3 (2023-25),58500000,19500000 897 | 2024,Guerrero Jr.,Vladimir,Blue Jays,1B,19900000,,, 898 | 2024,Morton,Charlie,Braves,RHP,20000000,,, 899 | 2024,Musgrove,Joe,Padres,RHP,20000000,5 (2023-27),100000000,20000000 900 | 2024,Castellanos,Nick,Phillies,OF,20000000,5 (2022-26),100000000,20000000 901 | 2024,Schwarber,Kyle,Phillies,DH,20000000,4 (2022-25),79000000,19750000 902 | 2024,Perez,Salvador,Royals,C,20000000,4 (2022-25),82000000,20500000 903 | 2024,Alonso,Pete,Mets,1B,20500000,,, 904 | 2024,Nimmo,Brandon,Mets,OF,20500000,8 (2023-30),162000000,20250000 905 | 2024,Marte,Starling,Mets,OF,20750000,4 (2022-25),78000000,19500000 906 | 2024,Riley,Austin,Braves,3B,21000000,10 (2023-32),212000000,21200000 907 | 2024,Happ,Ian,Cubs,OF,21000000,3 (2024-26),61000000,20333333 908 | 2024,Suzuki,Seiya,Cubs,OF,21000000,5 (2022-26),85000000,17000000 909 | 2024,Bassitt,Chris,Blue Jays,RHP,22000000,3 (2023-25),63000000,21000000 910 | 2024,Gausman,Kevin,Blue Jays,RHP,22000000,5 (2022-26),110000000,22000000 911 | 2024,Olson,Matt,Braves,1B,22000000,8 (2022-29),168000000,21000000 912 | 2024,Story,Trevor,Red Sox,SS,22500000,6 (2022-27),140000000,23333333.3333 913 | 2024,Ray,Robbie,Giants,LHP,23000000,5 (2022-26),115000000,23000000 914 | 2024,Hernandez,Teoscar,Dodgers,OF,23500000,,, 915 | 2024,Wheeler,Zack,Phillies,RHP,23500000,5 (2020-24),118000000,23600000 916 | 2024,Realmuto,JT,Phillies,C,23875000,5 (2021-25),115500000,23100000 917 | 2024,Castillo,Luis,Mariners,RHP,24150000,5 (2023-28),108000000,21600000 918 | 2024,Springer,George,Blue Jays,OF,24166667,6 (2021-26),150000000,25000000 919 | 2024,Yelich,Christian,Brewers,OF,24170234,9 (2020-28),215000000,23888888.8889 920 | 2024,Nola,Aaron,Phillies,RHP,24571428,7 (2024-30),172000000,24571429 921 | 2024,Moncada,Yoan,White Sox,3B,24800000,5 (2020-24),70000000,14000000 922 | 2024,Baez,Javier,Tigers,SS,25000000,6 (2022-27),140000000,23333333.3333 923 | 2024,Freeman,Freddie,Dodgers,1B,25144772,6 (2022-27),162000000,27000000 924 | 2024,Goldschmidt,Paul,Cardinals,1B,25333333,5 (2020-24),130000000,26000000 925 | 2024,Bogaerts,Xander,Padres,2B,25454545,11 (2023-33),280000000,25454545 926 | 2024,Swanson,Dansby,Cubs,SS,26000000,7 (2023-29),177000000,25285714 927 | 2024,Semien,Marcus,Rangers,2B,26000000,7(2022-28),175000000,25000000 928 | 2024,Betts,Mookie,Dodgers,SS,26158692,12 (2021-32),365000000,30416666.6667 929 | 2024,Devers,Rafael,Red Sox,3B,27066581,10 (2024-33),313500000,31350000 930 | 2024,Turner,Trea,Phillies,SS,27272727,11 (2023-33),300000000,27272727 931 | 2024,Bellinger,Cody,Cubs,OF,27500000,3 (2024-26),80000000,26666667 932 | 2024,Harper,Bryce,Phillies,1B,27538462,13 (2019-31),330000000,25384615.3846 933 | 2024,Rodon,Carlos,Yankees,LHP,27833333,6 (2023-28),162000000,27000000 934 | 2024,Bryant,Kris,Rockies,1B,28000000,7 (2022-28),182000000,26000000 935 | 2024,Altuve,Jose,Astros,2B,29000000,7 (2018-24),163500000,23357142.8571 936 | 2024,Bregman,Alex,Astros,3B,30500000,5 (2020-24),100000000,20000000 937 | 2024,Soto,Juan,Yankees,OF,31000000,,, 938 | 2024,Snell,Blake,Giants,LHP,32000000,2 (2024-25),62000000,31000000 939 | 2024,Stanton,Giancarlo,Yankees,DH,32000000,13 (2015-27),325000000,25000000 940 | 2024,Lindor,Francisco,Mets,SS,32477639,10 (2022-31),341000000,34100000 941 | 2024,Arenado,Nolan,Cardinals,3B,32675167,8 (2019-26),260000000,32500000 942 | 2024,Strasburg,Stephen,Nationals,RHP,32811200,7 (2020-26),245000000,35000000 943 | 2024,Correa,Carlos,Twins,SS,33333333,6 (2023-28),200000000,33333333 944 | 2024,Corbin,Patrick,Nationals,LHP,34556200,6 (2019-24),140000000,23333333.3333 945 | 2024,Seager,Corey,Rangers,SS,35000000,10 (2022-31),325000000,32500000 946 | 2024,Cole,Gerrit,Yankees,RHP,36000000,9 (2020-28),324000000,36000000 947 | 2024,Trout,Mike,Angels,OF,37116667,12 (2019-30),426500000,35541666.6667 948 | 2024,Rendon,Anthony,Angels,3B,38571429,7 (2020-26),245000000,35000000 949 | 2024,deGrom,Jacob,Rangers,RHP,40000000,5 (2023-27),185000000,37000000 950 | 2024,Judge,Aaron,Yankees,OF,40000000,9 (2023-31),360000000,40000000 951 | 2024,Verlander,Justin,Astros,RHP,43333333,2 (2023-24),86666666,43333333 952 | 2024,Scherzer,Max,Rangers,RHP,43333334,3 (2022-24),130000000,43333333.3333 953 | 2024,Ohtani,Shohei,Dodgers,DH/RHP,70000000,10 (2024-33),700000000,70000000 954 | --------------------------------------------------------------------------------