Pandas Basics
Use the Template
to explore the basic functionality of Pandas.
Create new cells with # %%
as necessary.
Use the Data Management section and the Pandas Documentation for help.
Template
# %%# Import Pandas# %%# Create a Pandas Series with the values 1-5 [pd.Series]# %%# Create a Pandas DataFrame with three columns, "x", "y", "z",# with values 1-5, 10-50, and A-E, respectively [pd.DataFrame]# %%# Inspect the DataFrame [.info, .describe]# %%# Index the DataFrame to pick out the:# - "x" column# - "x" and "y" columns# - [3, 30, C] row# - 40 cell# Use both label- and number-based indexing [.loc, .iloc]# %%# Add a new variable [.assign]:# - "a", that has the value 1 for all rows# - "b", that is the squared (pow 2) value of "x"# %%# Sort the DataFrame on [.sort_values, .sort_index]:# - "x", ascending# - "y", descending# - the index, descending# %%# Using method chaining, create a DataFrame as above but in one step:# - DataFrame with columns "x", "y", and "z"# - Add the columns "a" and "b"# - Sort on "y", descending