When you have a larger DataFrame, you might want to select just a few columns.
For instance, let’s return to a DataFrame of
orders from ShoeFly.com:
|53450||Emily||Joyce||[email protected]||ballet flats||faux-leather||navy|
We might just be interested in the customer’s
To select two or more columns from a DataFrame, we use a list of the column names. To create the DataFrame shown above, we would use:
new_df = orders[['last_name', 'email']]
Note: Make sure that you have a double set of brackets (
[]), or this command won’t work!
Now, you want to compare visits to the Northern and Southern clinics.
Create a variable called
clinic_north_south that contains ONLY the data from the columns
When we select multiple columns, do we get a Series or a DataFrame?
After you’ve created the variable, enter the command:
to see what data type you’ve created.
How is this different from what happened in the previous exercise?