Statement of Completion#a96dd319
Intro to Pandas for Data Analysis
easy
Exploring Pandas with a Bakery Transaction Dataset
Resolution
Activities
Project.ipynb
Exploring Pandas with The Bread Basket¶
In [3]:
# Begin by importing the libraries
import numpy as np
import pandas as pd
Conceptual Questions¶
1. What is pandas ?¶
In [ ]:
# what is pandas ?
2. What are the two main types of data structure in pandas?¶
In [ ]:
# What are the two main types of data structure in Pandas?
3. Which of the following is NOT a method for reading data into pandas?¶
In [ ]:
# Which of the following is NOT a method for reading data into pandas?
4. Which function is used to create a pandas DataFrame from a dictionary?¶
In [ ]:
# Which function is used to create a pandas DataFrame from a dictionary?
5. Which function is used to load CSV files in pandas?¶
In [ ]:
# Which function is used to load CSV files in pandas?
6. Which of these methods can display the first five rows of a DataFrame?¶
In [ ]:
# Which of these methods can display the first few rows of a DataFrame?
Working with Dataset¶
7. Load the dataset¶
In [1]:
!ls
Project.ipynb bread-basket.csv
In [4]:
df_data = pd.read_csv("bread-basket.csv")
8. Display the Last 10 Rows¶
In [10]:
last_ten = df_data.tail(10)
last_ten
Out[10]:
| Transaction | Item | date_time | period_day | weekday_weekend | |
|---|---|---|---|---|---|
| 20497 | 9681 | Tea | 09-04-2017 14:30 | afternoon | weekend |
| 20498 | 9681 | Spanish Brunch | 09-04-2017 14:30 | afternoon | weekend |
| 20499 | 9681 | Christmas common | 09-04-2017 14:30 | afternoon | weekend |
| 20500 | 9682 | Muffin | 09-04-2017 14:32 | afternoon | weekend |
| 20501 | 9682 | Tacos/Fajita | 09-04-2017 14:32 | afternoon | weekend |
| 20502 | 9682 | Coffee | 09-04-2017 14:32 | afternoon | weekend |
| 20503 | 9682 | Tea | 09-04-2017 14:32 | afternoon | weekend |
| 20504 | 9683 | Coffee | 09-04-2017 14:57 | afternoon | weekend |
| 20505 | 9683 | Pastry | 09-04-2017 14:57 | afternoon | weekend |
| 20506 | 9684 | Smoothies | 09-04-2017 15:04 | afternoon | weekend |
9. How to find out the data type of Transaction column?¶
In [ ]:
# Checking the Data Types
10. What does the following code do?¶
In [ ]:
# What does the following code do?
11. Which of the following is the correct syntax to get a summary of non-null values and data types for each column in a DataFrame df?¶
In [13]:
# Which of the following is the correct syntax to get a summary of non-null values and data types for each column in a DataFrame df?
df_data.describe()
Out[13]:
| Transaction | |
|---|---|
| count | 20507.000000 |
| mean | 4976.202370 |
| std | 2796.203001 |
| min | 1.000000 |
| 25% | 2552.000000 |
| 50% | 5137.000000 |
| 75% | 7357.000000 |
| max | 9684.000000 |
12. Which of the following is the correct way to view the unique items bought in the Item column?¶
In [ ]:
# Which of the following is the correct way to view the unique items bought in the `Item` column?