{"id":13499925,"url":"https://github.com/jvns/pandas-cookbook","last_synced_at":"2025-05-14T01:02:19.482Z","repository":{"id":12690254,"uuid":"15362532","full_name":"jvns/pandas-cookbook","owner":"jvns","description":"Recipes for using Python's pandas library","archived":false,"fork":false,"pushed_at":"2024-10-24T02:01:47.000Z","size":12942,"stargazers_count":6774,"open_issues_count":35,"forks_count":2334,"subscribers_count":301,"default_branch":"master","last_synced_at":"2025-04-23T17:11:38.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"fmoctezuma/spacemonkey","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jvns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-21T17:14:38.000Z","updated_at":"2025-04-21T08:18:38.000Z","dependencies_parsed_at":"2022-07-12T13:33:58.401Z","dependency_job_id":"8c8153d8-643b-4fef-8418-169d71bf05dc","html_url":"https://github.com/jvns/pandas-cookbook","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvns%2Fpandas-cookbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvns%2Fpandas-cookbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvns%2Fpandas-cookbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvns%2Fpandas-cookbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jvns","download_url":"https://codeload.github.com/jvns/pandas-cookbook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477810,"owners_count":21437049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:00:47.679Z","updated_at":"2025-04-23T17:12:06.087Z","avatar_url":"https://github.com/jvns.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","others","Python","Jupyter Notebook (27)","Uncategorized","(1)  :panda_face: pandas resources","🐍 Python"],"sub_categories":["General-Purpose Machine Learning","Uncategorized","(1.3) :mortar_board: Tutorials","Data Manipulation with Pandas and Numpy"],"readme":"Pandas cookbook\n===============\n\nTry it in your browser with Jupyter Lite: [![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://jvns.github.io/pandas-cookbook/lab/index.html)\n\n[pandas](http://pandas.pydata.org/) is a Python library for doing\ndata analysis. It's really fast and lets you do exploratory work\nincredibly quickly.\n\nThe goal of this cookbook is to give you some concrete examples for\ngetting started with pandas. The [docs](http://pandas.pydata.org/pandas-docs/stable/)\nare really comprehensive. However, I've often had people\ntell me that they have some trouble getting started, so these are\nexamples with real-world data, and all the bugs and weirdness\nthat entails.\n\nIt uses 3 datasets:\n\n* 311 calls in New York\n* How many people were on Montréal's bike paths in 2012\n* Montreal's weather for 2012, hourly\n\nIt comes with batteries (data) included, so you can try out all the\nexamples right away.\n\nTable of Contents\n=================\n\n\n* [A quick tour of the Jupyter Notebook](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/A%20quick%20tour%20of%20%20Notebook.ipynb)\n  \u003cbr\u003e Shows off Jupyter's awesome tab completion and magic functions.\n* [Chapter 1: Reading from a CSV](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%201%20-%20Reading%20from%20a%20CSV.ipynb)\n  \u003cbr\u003e Reading your data into pandas is pretty much the easiest thing. Even when the encoding is wrong!\n* [Chapter 2: Selecting data \u0026 finding the most common complaint type](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%202%20-%20Selecting%20data%20\u0026%20finding%20the%20most%20common%20complaint%20type.ipynb)\n  \u003cbr\u003eIt's not totally obvious how to select data from a pandas dataframe. Here I explain the basics (how to take slices and get columns)\n* [Chapter 3: Which borough has the most noise complaints? (or, more selecting data)](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%203%20-%20Which%20borough%20has%20the%20most%20noise%20complaints%20%28or%2C%20more%20selecting%20data%29.ipynb)\n  \u003cbr\u003eHere we get into serious slicing and dicing and learn how to filter dataframes in complicated ways, really fast.\n* [Chapter 4: Find out on which weekday people bike the most with groupby and aggregate](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%204%20-%20Find%20out%20on%20which%20weekday%20people%20bike%20the%20most%20with%20groupby%20and%20aggregate.ipynb)\n  \u003cbr\u003e The groupby/aggregate is seriously my favorite thing about pandas and I use it all the time. You should probably read this.\n* [Chapter 5: Combining dataframes and scraping Canadian weather data](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%205%20-%20Combining%20dataframes%20and%20scraping%20Canadian%20weather%20data.ipynb)\n  \u003cbr\u003eHere you get to find out if it's cold in Montreal in the winter (spoiler: yes). Web scraping with pandas is fun!\n* [Chapter 6: String operations! Which month was the snowiest?](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%206%20-%20String%20Operations-%20Which%20month%20was%20the%20snowiest.ipynb)\n  \u003cbr\u003e Strings with pandas are great. It has all these vectorized string operations and they're the best. We will turn a bunch of strings containing \"Snow\" into vectors of numbers in a trice.\n* [Chapter 7: Cleaning up messy data](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%207%20-%20Cleaning%20up%20messy%20data.ipynb)\n  \u003cbr\u003e Cleaning up messy data is never a joy, but with pandas it's easier \u0026lt;3\n* [Chapter 8: Parsing Unix timestamps](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%208%20-%20How%20to%20deal%20with%20timestamps.ipynb)\n  \u003cbr\u003e This is basically a quick trick that took me 2 days to figure out.\n* [Chapter 9 - Loading data from SQL databases](https://nbviewer.org/github/jvns/pandas-cookbook/blob/master/cookbook/Chapter%209%20-%20Loading%20data%20from%20SQL%20databases.ipynb)\n  \u003cbr\u003e How to load data from an SQL database into Pandas, with examples using SQLite3, PostgreSQL, and MySQL.\n\nHow to use this cookbook\n========================\n\nYou can try it out instantly online using [Jupyter Lite](https://jvns.github.io/pandas-cookbook/lab/index.html), which will run Python with WebAssembly in your browser.\n\nTo install it locally, you'll need Jupyter notebook and pandas on your computer.\n\nYou can get these using `pip` (you may want to do this inside a virtual environment to avoid conflicting with your other libraries).\n\n```bash\n# Get the repository\ngit clone https://github.com/jvns/pandas-cookbook.git\ncd pandas-cookbook\n\n# Set up a virtual environment\npython3 -m venv venv\nsource venv/bin/activate\n\n# Install dependencies\npip install -r requirements.txt\n\n# Start jupyter\njupyter notebook\n```\n\nA tab should open up in your browser at `http://localhost:8888`\n\nHappy pandas!\n\nRunning the cookbook inside a Docker container.\n===============================================================\nThis repository contains a Dockerfile and can be built into a docker container.\nTo build the container run following command from inside of the repository directory:\n```\ndocker build -t jvns/pandas-cookbook -f Dockerfile-Local .\n```\nrun the container:\n```\ndocker run -d -p 8888:8888 -e \"PASSWORD=MakeAPassword\" \u003cIMAGE ID\u003e\n```\nyou can find out about the id of the image, by checking\n```\ndocker images\n```\n\nAfter starting the container, you can access the Jupyter notebook with the cookbook\non port 8888. \n\nLicense\n=======\n\n\u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/4.0/\"\u003e\u003cimg alt=\"Creative Commons License\" style=\"border-width:0\" src=\"http://i.creativecommons.org/l/by-sa/4.0/88x31.png\" /\u003e\u003c/a\u003e\u003cbr /\u003e\n\nThis work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/)\n\n## Translations\n\nThere's [a translation into Chinese of this repo](https://github.com/ia-cas/pandas-cookbook).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvns%2Fpandas-cookbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjvns%2Fpandas-cookbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvns%2Fpandas-cookbook/lists"}