{"id":21,"date":"2023-09-13T09:56:18","date_gmt":"2023-09-13T09:56:18","guid":{"rendered":"http:\/\/harvard-open-data-project.local\/?page_id=21"},"modified":"2023-09-14T01:54:42","modified_gmt":"2023-09-14T01:54:42","slug":"data-wrangling-with-python-intermediate","status":"publish","type":"page","link":"http:\/\/harvard-open-data-project.local\/data-wrangling-with-python-intermediate\/","title":{"rendered":"Data Wrangling with Python – Intermediate"},"content":{"rendered":"\n

Python is known for its incredible versatility and simplicity in handling data, making it an excellent tool for data wrangling. This article will delve into the intermediate aspects of Python, such as file manipulation and reading CSV files. This guide assumes a basic knowledge of Python and Python syntax. If you need a refresher on Python basics, check out HODP’s Python for beginners guid<\/a>e<\/a>.<\/p>\n\n\n\n

File Input\/Output (I\/O)<\/h2>\n\n\n\n

File I\/O operations are crucial in Python, especially when dealing with large amounts of data stored outside of Python, such as Excel spreadsheets. Python makes it easy to read and write files in different modes, making data manipulation efficient and straightforward.<\/p>\n\n\n\n

Opening Files<\/h3>\n\n\n\n

To open a file in Python, we use the built-in open()<\/code> function. open()<\/code> takes two arguments, the file’s name (or path) and the mode in which we want to open the file.<\/p>\n\n\n\n

Python provides different modes for opening a file. The common modes are:<\/p>\n\n\n\n