2. Data frame Functions and Properties

Very Easy assignments

  1. Load the dataset and display.

Solution
import pandas as pd
df=pd.read_csv('retail_data.csv')
df

# Output


Transaction_ID	Customer_ID	Name	Email	Phone	Address	City	State	Zipcode	Country	...	Total_Amount	Product_Category	Product_Brand	Product_Type	Feedback	Shipping_Method	Payment_Method	Order_Status	Ratings	products
0	8691788	37249	Michelle Harrington	Ebony39@gmail.com	1414786801	3959 Amanda Burgs	Dortmund	Berlin	77985	Germany	...	324.086270	Clothing	Nike	Shorts	Excellent	Same-Day	Debit Card	Shipped	5	Cycling shorts
1	2174773	69749	Kelsey Hill	Mark36@gmail.com	6852899987	82072 Dawn Centers	Nottingham	England	99071	UK	...	806.707815	Electronics	Samsung	Tablet	Excellent	Standard	Credit Card	Processing	4	Lenovo Tab
2	6679610	30192	Scott Jensen	Shane85@gmail.com	8362160449	4133 Young Canyon	Geelong	New South Wales	75929	Australia	...	1063.432799	Books	Penguin Books	Children's	Average	Same-Day	Credit Card	Processing	2	Sports equipment
3	7232460	62101	Joseph Miller	Mary34@gmail.com	2776751724	8148 Thomas Creek Suite 100	Edmonton	Ontario	88420	Canada	...	2466.854021	Home Decor	Home Depot	Tools	Excellent	Standard	PayPal	Processing	4	Utility knife
4	4983775	27901	Debra Coleman	Charles30@gmail.com	9098267635	5813 Lori Ports Suite 269	Bristol	England	48704	UK	...	248.553049	Grocery	Nestle	Chocolate	Bad	Standard	Cash	Shipped	1	Chocolate cookies
...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...	...
293906	4246475	12104	Meagan Ellis	Courtney60@gmail.com	7466353743	389 Todd Path Apt. 159	Townsville	New South Wales	4567	Australia	...	973.962984	Books	Penguin Books	Fiction	Bad	Same-Day	Cash	Processing	1	Historical fiction
293907	1197603	69772	Mathew Beck	Jennifer71@gmail.com	5754304957	52809 Mark Forges	Hanover	Berlin	16852	Germany	...	285.137301	Electronics	Apple	Laptop	Excellent	Same-Day	Cash	Processing	5	LG Gram
293908	7743242	28449	Daniel Lee	Christopher100@gmail.com	9382530370	407 Aaron Crossing Suite 495	Brighton	England	88038	UK	...	182.105285	Clothing	Adidas	Jacket	Average	Express	Cash	Shipped	2	Parka
293909	9301950	45477	Patrick Wilson	Rebecca65@gmail.com	9373222023	3204 Baird Port	Halifax	Ontario	67608	Canada	...	120.834784	Home Decor	IKEA	Furniture	Good	Standard	Cash	Shipped	4	TV stand
293910	2882826	53626	Dustin Merritt	William14@gmail.com	9518926645	143 Amanda Crescent	Tucson	West Virginia	25242	USA	...	2382.233417	Home Decor	Home Depot	Decorations	Average	Same-Day	Cash	Shipped	2	Clocks
293911 rows × 30 columns
  1. Check the number of rows and columns in the dataset.

Solution
df.shape

# Output
(293911, 30)
  1. Check details for index numbers in the dataset.

Solution
df.index

# Output

RangeIndex(start=0, stop=293911, step=1)
  1. Display all the columns of this dataset.

Solution

  1. Check out the data type for each column.

Solution
  1. Create a sample dataset of 10 rows from the existing dataset.

Solution
  1. Display the statistical summary of the dataset.

Solution
  1. Check out the information on all the columns of the dataset of retail data.

Solution
  1. Display the top 5 rows of the dataset.

Solution
  1. Display the top 12 rows of the dataset.

Solution
  1. Display 5 rows from the bottom.

Solution
  1. Display 8 bottom rows.

Solution

Easy Assignments

  1. Check out the number of data and data-type of each column in the dataset.

Solution
  1. Display the first few rows of the dataset.

Solution
  1. Present the first 9 rows of the dataset.

Solution
  1. Reveal the bottom rows of the dataset.

Solution
  1. Display the last 25 liquor data of the dataset.

Solution
  1. Show a detailed summary of the dataset, highlighting key metrics such as mean, median, standard deviation, minimum, maximum, and count for each numerical column, as well as unique counts for categorical variables.

Solution
  1. Display the number of rows and columns in the dataset separately.

Solution
  1. Generate a sample dataset containing 30 rows based on the current dataset.

Solution

Last updated