Chapter 01: The Python Data Science Stack
Activity 1: IPython and Jupyter
Open the python_script_student.py file in a text editor, copy the contents to a notebook in IPython, and execute the operations.
Copy and paste the code from the Python script into a Jupyter notebook:
import numpy as np def square_plus(x, c): return np.power(x, 2) + cNow, update the values of the x and c variables. Then, change the definition of the function:
x = 10 c = 100 result = square_plus(x, c) print(result)
The output is as follows:
200
Activity 2: Working with Data Problems
Import pandas and NumPy library:
import pandas as pd import numpy as np
Read the RadNet dataset from the U.S. Environmental Protection Agency, available from the Socrata project:
url = "https://opendata.socrata.com/api/views/cf4r-dfwe/rows.csv?accessType=DOWNLOAD" df = pd.read_csv(url)
Create a list with numeric columns for radionuclides in the RadNet dataset:
columns = df.columns id_cols = ['State', 'Location', "Date Posted", 'Date Collected'...