Today we’ll perform data cleaning and preprocessing on a real-world dataset. Write the…
- User
Today we’ll perform data cleaning and preprocessing on a real-world dataset. Write the code to do the following: 1. Fetch the bank marketing dataset from the UCI machine learning repository. Use libraries like requests or urllib. 2. Download the zip file, unzip the contents, and read in the bank-full.csv file into a pandas dataframe (call it data).
Assistant
Here is the code to fetch the bank marketing dataset and load it into a pandas dataframe:
pythonimport pandas as pd import requests from zipfile import ZipFile # Download the zip file url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/00222/bank-additional-full.zip' r = requests.get(url) # Unzip the contents zip_ref = ZipFile(io.BytesIO(r.content)) zip_ref.extractall() zip_ref.close() # Load the csv file into a dataframe data = pd.read_csv('bank-additional-full.csv')
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.