9 Libraries
9 Libraries
In [1]: import math #### Math - a library that is used for math function
In [3]: math.cos(90)
Out[3]: -0.4480736161291701
In [4]: math.factorial(5) # factorial - multiply all the numbers behind the given number until 0
Out[4]: 120
In [5]: math.lcm(6,4)
Out[5]: 12
In [6]: math.gcd(6,4)
Out[6]: 2
In [7]: math.exp(4)
Out[7]: 54.598150033144236
In [9]: math.pow(5,2)
Out[9]: 25.0
In [10]: math.log(5)
Out[10]: 1.6094379124341003
Out[11]: 3.1622776601683795
In [16]: math.pi
Out[16]: 3.141592653589793
In [ ]: sc.
Out[130… (301, 8)
In [131… car_data.columns
In [132… list(car_data.columns)
Out[132… ['Car_Name',
'Year',
'Selling_Price',
'Present_Price',
'Kms_Driven',
'Fuel_Type',
'Seller_Type',
'Transmission']
In [234… car_data.count()
In [133… type(car_data)
# Dataframe
#2D tabular form (column and rows)
#similar to table or spreadsheet
Out[133… pandas.core.frame.DataFrame
In [134… car_data.dtypes
In [138… car_data[car_data["Year"] == 2014].head(5) # similar to (select * from car_data where yaer = 2014)
100 Royal Enfield Thunder 500 2016 1.75 1.90 3000 Petrol Individual Manual
101 UM Renegade Mojave 2017 1.70 1.82 1400 Petrol Individual Manual
177 Honda Activa 125 2016 0.35 0.57 24000 Petrol Individual Automatic
In [148… pd.set_option("display.max_rows",20) ## it sets the limit to the records that will be displayed
In [149… car_data.head(200) # by restricting the rows to 20, even if we ask for 200 records it will display only 20
195 Bajaj ct 100 2015 0.18 0.32 35000 Petrol Individual Manual
197 Honda CB twister 2010 0.16 0.51 33000 Petrol Individual Manual
198 Bajaj Discover 125 2011 0.15 0.57 35000 Petrol Individual Manual
199 Honda CB Shine 2007 0.12 0.58 53000 Petrol Individual Manual
In [151… type(emp_data)
Out[151… pandas.core.frame.DataFrame
In [152… emp_data.shape
In [153… emp_data.columns
In [154… emp_data.head(3)
Out[154… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 M M 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
1 2 253022876 adventure-works\kevin0 Catherine Abel 9.453570e+09 12-03-1991 00:00 S M 31-08-2013 00:00 Sales 962.0 Management -1 {1B480240-95C0-410F-A717-EB29943C8886}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 M M 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
In [ ]: #Method 1
In [155… emp_data[emp_data["Dept"]=="sales"].head(3)
Out[155… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
6 7 309738752 NaN Margaret Smith NaN 25-11-1959 00:00 S F 31-07-2014 00:00 sales NaN Operations -1 {2CC71B96-F421-485E-9832-8723337749BB}
18 19 9659517 NaN Milton Albury NaN 06-02-1960 00:00 M F 01-11-2014 00:00 sales 3408.0 Admin -1 {C334B2D2-0C56-4906-9095-F1D07A98CBEC}
40 41 885055826 NaN John Arthur 7.945558e+09 26-01-1980 00:00 M M 15-07-2018 00:00 sales 1355.0 Admin -1 {E249D613-36C9-4544-9B6F-6CE50E5E0DA5}
In [ ]: #Method 1a
In [156… emp_data[emp_data["Dept"]=="sales"][["Title","Dept","Gender"]].head(3) ### Desired columns should be written in double square brackets
In [157… emp_data.query('Dept=="sales"').head(3)
Out[157… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
6 7 309738752 NaN Margaret Smith NaN 25-11-1959 00:00 S F 31-07-2014 00:00 sales NaN Operations -1 {2CC71B96-F421-485E-9832-8723337749BB}
18 19 9659517 NaN Milton Albury NaN 06-02-1960 00:00 M F 01-11-2014 00:00 sales 3408.0 Admin -1 {C334B2D2-0C56-4906-9095-F1D07A98CBEC}
40 41 885055826 NaN John Arthur 7.945558e+09 26-01-1980 00:00 M M 15-07-2018 00:00 sales 1355.0 Admin -1 {E249D613-36C9-4544-9B6F-6CE50E5E0DA5}
In [ ]: # Method 3 ---- (loc or iloc) ###loc- label based indexing --- not to use, just for knowledge
In [159… emp_data.loc[emp_data["Dept"]=="sales"].head(3)
Out[159… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
6 7 309738752 NaN Margaret Smith NaN 25-11-1959 00:00 S F 31-07-2014 00:00 sales NaN Operations -1 {2CC71B96-F421-485E-9832-8723337749BB}
18 19 9659517 NaN Milton Albury NaN 06-02-1960 00:00 M F 01-11-2014 00:00 sales 3408.0 Admin -1 {C334B2D2-0C56-4906-9095-F1D07A98CBEC}
40 41 885055826 NaN John Arthur 7.945558e+09 26-01-1980 00:00 M M 15-07-2018 00:00 sales 1355.0 Admin -1 {E249D613-36C9-4544-9B6F-6CE50E5E0DA5}
In [ ]: # Method 3a
In [160… emp_data.loc[emp_data["Dept"]=="sales"][["Title","Dept","Gender"]].head(3)
Out[161… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
40 41 885055826 NaN John Arthur 7.945558e+09 26-01-1980 00:00 M M 15-07-2018 00:00 sales 1355.0 Admin -1 {E249D613-36C9-4544-9B6F-6CE50E5E0DA5}
Out[163… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 M M 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 M M 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
4 5 480168528 NaN Pilar Ackerman NaN 07-06-1963 00:00 M M 16-07-2014 00:00 Human Resource 1932.0 Admin -1 {1D955171-E773-4FAD-8382-40FD898D5D4D}
In [165… emp_data.query('Gender == "M" and MaritalStatus == "M"').head(3) # IN the query method fields should be written
# between a single inverted comma ''
Out[165… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 M M 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 M M 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
4 5 480168528 NaN Pilar Ackerman NaN 07-06-1963 00:00 M M 16-07-2014 00:00 Human Resource 1932.0 Admin -1 {1D955171-E773-4FAD-8382-40FD898D5D4D}
In [ ]: # Summery
# Normal method with single column filteration (all columns, selected columns)
# normal method with multiple column filteration (all column, selected columns)
# Query method with single column filteration (all columns, selected columns)
# Query method with multiple column filteration (all columns, selected columns)
# loc method with single column filteration (all columns, selected columns)
# loc method with multiple column filteration (all columns, selected columns)
In [64]: add(5,6)
Out[64]: 11
In [67]: MaritalStatus("M")
Out[67]: 'Married'
In [68]: MaritalStatus("S")
Out[68]: 'Single'
In [75]: Gender("M")
Out[75]: 'Male'
In [76]: Gender("F")
Out[76]: 'Female'
In [167… emp_data.head(3)
Out[167… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 M M 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
1 2 253022876 adventure-works\kevin0 Catherine Abel 9.453570e+09 12-03-1991 00:00 S M 31-08-2013 00:00 Sales 962.0 Management -1 {1B480240-95C0-410F-A717-EB29943C8886}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 M M 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
In [168… emp_data["Gender"]=emp_data["Gender"].apply(Gender)
In [169… emp_data.head(3)
Out[169… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 M Male 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
1 2 253022876 adventure-works\kevin0 Catherine Abel 9.453570e+09 12-03-1991 00:00 S Male 31-08-2013 00:00 Sales 962.0 Management -1 {1B480240-95C0-410F-A717-EB29943C8886}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 M Male 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
In [171… emp_data.head(3)
Out[171… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 Married Male 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
1 2 253022876 adventure-works\kevin0 Catherine Abel 9.453570e+09 12-03-1991 00:00 Single Male 31-08-2013 00:00 Sales 962.0 Management -1 {1B480240-95C0-410F-A717-EB29943C8886}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 Married Male 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
In [173… type(bike_data)
Out[173… pandas.core.frame.DataFrame
In [174… bike_data.shape
In [175… bike_data.dtypes
In [176… bike_data.head(5) # the data does not have any measuring column e.g sales, profit etc.
Out[176… Region Country Customer Business Segment Category Model Color SalesDate ListPrice UnitPrice OrderQty
0 North America United States Advanced Bike Components Components Road Frames LL Road Frame Red 2020-04-01 337.22 183.94 1
1 North America United States Central Discount Store Bikes Mountain Bikes Mountain-100 Silver 2020-04-01 3399.99 2039.99 1
2 North America United States Leading Sales & Repair Clothing Jerseys Long-Sleeve Logo Jersey Multi 2020-04-01 49.99 28.84 6
3 North America United States Paint Supply Components Mountain Frames HL Mountain Frame Black 2020-04-01 1349.60 714.70 2
4 North America United States Scooters and Bikes Store Bikes Road Bikes Road-450 Red 2020-04-01 1457.99 874.79 2
In [178… bike_data.head(5)
Out[178… Region Country Customer Business Segment Category Model Color SalesDate ListPrice UnitPrice OrderQty cost
0 North America United States Advanced Bike Components Components Road Frames LL Road Frame Red 2020-04-01 337.22 183.94 1 183.94
1 North America United States Central Discount Store Bikes Mountain Bikes Mountain-100 Silver 2020-04-01 3399.99 2039.99 1 2039.99
2 North America United States Leading Sales & Repair Clothing Jerseys Long-Sleeve Logo Jersey Multi 2020-04-01 49.99 28.84 6 173.04
3 North America United States Paint Supply Components Mountain Frames HL Mountain Frame Black 2020-04-01 1349.60 714.70 2 1429.40
4 North America United States Scooters and Bikes Store Bikes Road Bikes Road-450 Red 2020-04-01 1457.99 874.79 2 1749.58
In [190… bike_data.head(5)
Out[190… Region Country Customer Business Segment Category Model Color SalesDate ListPrice UnitPrice OrderQty cost Profit Sales
0 North America United States Advanced Bike Components Components Road Frames LL Road Frame Red 2020-04-01 337.22 183.94 1 183.94 153.28 337.22
1 North America United States Central Discount Store Bikes Mountain Bikes Mountain-100 Silver 2020-04-01 3399.99 2039.99 1 2039.99 1360.00 3399.99
2 North America United States Leading Sales & Repair Clothing Jerseys Long-Sleeve Logo Jersey Multi 2020-04-01 49.99 28.84 6 173.04 126.90 299.94
3 North America United States Paint Supply Components Mountain Frames HL Mountain Frame Black 2020-04-01 1349.60 714.70 2 1429.40 1269.80 2699.20
4 North America United States Scooters and Bikes Store Bikes Road Bikes Road-450 Red 2020-04-01 1457.99 874.79 2 1749.58 1166.40 2915.98
In [193… bike_data.head(5)
Out[193… Region Country Customer Business Segment Category Model Color SalesDate ListPrice UnitPrice OrderQty cost Profit Sales
0 North America United States Advanced Bike Components Components Road Frames LL Road Frame Red 2020-04-01 337.22 183.94 1 183.94 153.28 337.22
1 North America United States Central Discount Store Bikes Mountain Bikes Mountain-100 Silver 2020-04-01 3399.99 2039.99 1 2039.99 1360.00 3399.99
2 North America United States Leading Sales & Repair Clothing Jerseys Long-Sleeve Logo Jersey Multi 2020-04-01 49.99 28.84 6 173.04 126.90 299.94
3 North America United States Paint Supply Components Mountain Frames HL Mountain Frame Black 2020-04-01 1349.60 714.70 2 1429.40 1269.80 2699.20
4 North America United States Scooters and Bikes Store Bikes Road Bikes Road-450 Red 2020-04-01 1457.99 874.79 2 1749.58 1166.40 2915.98
In [ ]: # I accidentally added an extra column("sales") to the data frame. dropped the "sales" column
# drop("sales, axis=1): Specify that you want to drop the column named 'B'.
# The axis=1 parameter indicates that you're dropping a column (use axis=0 to drop rows).
# inplace=True: If you want to modify the original DataFrame without creating a new one, use inplace = True.
In [196… bike_data.head(5)
Out[196… Region Country Customer Business Segment Category Model Color SalesDate ListPrice UnitPrice OrderQty cost Profit Sales
0 North America United States Advanced Bike Components Components Road Frames LL Road Frame Red 2020-04-01 337.22 183.94 1 183.94 153.28 337.22
1 North America United States Central Discount Store Bikes Mountain Bikes Mountain-100 Silver 2020-04-01 3399.99 2039.99 1 2039.99 1360.00 3399.99
2 North America United States Leading Sales & Repair Clothing Jerseys Long-Sleeve Logo Jersey Multi 2020-04-01 49.99 28.84 6 173.04 126.90 299.94
3 North America United States Paint Supply Components Mountain Frames HL Mountain Frame Black 2020-04-01 1349.60 714.70 2 1429.40 1269.80 2699.20
4 North America United States Scooters and Bikes Store Bikes Road Bikes Road-450 Red 2020-04-01 1457.99 874.79 2 1749.58 1166.40 2915.98
In [197… # Assign Catagories(Platinum, Gold, Silver) to the customers based on the sales
def Sales_group(a):
if a < 5000:
return "Bronze"
elif a < 10000:
return "Silver"
elif a < 15000:
return "Gold"
else:
return"Platinum"
In [198… Sales_group(18000)
Out[198… 'Platinum'
In [201… bike_data.head(5)
Out[201… Region Country Customer Business Segment Category Model Color SalesDate ListPrice UnitPrice OrderQty cost Profit Sales Customer_segment
0 North America United States Advanced Bike Components Components Road Frames LL Road Frame Red 2020-04-01 337.22 183.94 1 183.94 153.28 337.22 Bronze
1 North America United States Central Discount Store Bikes Mountain Bikes Mountain-100 Silver 2020-04-01 3399.99 2039.99 1 2039.99 1360.00 3399.99 Bronze
2 North America United States Leading Sales & Repair Clothing Jerseys Long-Sleeve Logo Jersey Multi 2020-04-01 49.99 28.84 6 173.04 126.90 299.94 Bronze
3 North America United States Paint Supply Components Mountain Frames HL Mountain Frame Black 2020-04-01 1349.60 714.70 2 1429.40 1269.80 2699.20 Bronze
4 North America United States Scooters and Bikes Store Bikes Road Bikes Road-450 Red 2020-04-01 1457.99 874.79 2 1749.58 1166.40 2915.98 Bronze
In [204… bike_data.columns
#Ans. When the data is present on the database we use SQL and when the data is present in the files we use Python
In [206… crime_data.head(5)
In [207… cdata = crime_data[["Category", "State/UT", "Total"]] # to display only state/UT and no of crimes
In [208… cdata.head(5)
22 State Sikkim 3
18 State Nagaland 4
17 State Mizoram 17
25 State Tripura 35
In [ ]: #Assignment:-
# Add new column as Risk
# for <2000 crimes --. low risk
# for 2000 to 4000 crimes ---. moderate risk
# for 4000 to 6000 crimes ---. high risk
In [211… car_data.head(5)
189 Hero Super Splendor 2005 0.20 0.57 55000 Petrol Individual Manual
191 Bajaj Discover 125 2012 0.20 0.57 25000 Petrol Individual Manual
193 Hero Ignitor Disc 2013 0.20 0.65 24000 Petrol Individual Manual
190 Bajaj Pulsar 150 2008 0.20 0.75 60000 Petrol Individual Manual
195 Bajaj ct 100 2015 0.18 0.32 35000 Petrol Individual Manual
In [222… # mistake that i have made while writting the above line was not to assign a dataframe e.g car_data1.
# instead i have made changes directly to the original dataframe thats a strict no no
# it should be
car_data.sort_values(by=["Selling_Price", "Present_Price"]).head(5)
200 Bajaj Pulsar 150 2006 0.10 0.75 92233 Petrol Individual Manual
199 Honda CB Shine 2007 0.12 0.58 53000 Petrol Individual Manual
198 Bajaj Discover 125 2011 0.15 0.57 35000 Petrol Individual Manual
197 Honda CB twister 2010 0.16 0.51 33000 Petrol Individual Manual
In [ ]: # Assignment:-
# Q. Try to sort two columns, one is ascending and one is descending
In [223… car_data.head(5)
Out[229… 38
Out[232… 61
Out[230… 60
In [245… car_data.groupby("Year")[["Car_Name"]].count()
### have to use double square brackets [[]] to ensure the result is a dataframe
Out[245… Car_Name
Year
2003 2
2004 1
2005 4
2006 4
2007 2
2008 7
2009 6
2010 15
2011 19
2012 23
2013 33
2014 38
2015 61
2016 50
2017 35
2018 1
In [238… car_data.groupby("Fuel_Type")[["Car_Name"]].count()
Out[238… Car_Name
Fuel_Type
CNG 2
Diesel 60
Petrol 239
In [239… car_data.groupby("Transmission")[["Car_Name"]].count()
Out[239… Car_Name
Transmission
Automatic 40
Manual 261
In [ ]: # when putting two columns in the group by we have to put it in a list format
Out[244… Car_Name
Fuel_Type Transmission
CNG Manual 2
Diesel Automatic 12
Manual 48
Petrol Automatic 28
Manual 211
In [247… emp_data.head(3)
Out[247… EmployeeID NationalIDNumber LoginID Title PhoneNumber BirthDate MaritalStatus Gender HireDate Dept Salary Job Grade CurrentFlag rowguid
0 1 14417807 adventure-works\guy1 Gustavo Achong 8.185304e+09 21-02-1986 00:00 Married Male 02-02-2013 00:00 Sales 2295.0 Admin -1 {AAE1D04A-C237-4974-B4D5-935247737718}
1 2 253022876 adventure-works\kevin0 Catherine Abel 9.453570e+09 12-03-1991 00:00 Single Male 31-08-2013 00:00 Sales 962.0 Management -1 {1B480240-95C0-410F-A717-EB29943C8886}
2 3 509647174 NaN Kim Abercrombie 9.513804e+09 21-09-1978 00:00 Married Male 16-06-2014 00:00 Finance 4006.0 Admin -1 {9BBBFB2C-EFBB-4217-9AB7-F97689328841}
Out[249… EmployeeID
MaritalStatus Gender
Married Female 7
Male 15
Single Female 6
Male 22
In [253… emp_data.groupby("Dept")[["EmployeeID"]].count()
Out[253… EmployeeID
Dept
Finance 11
Human Resource 6
Logistics 8
Production 14
Sales 7
sales 4
In [256… import warnings ### to remove the warnings that comes after fetching a dataset
In [257… warnings.filterwarnings("ignore")
In [261… Storedata.head(3)
CA-2016- 2016-03- 2016-03- Standard Home TEC-MA- Cisco TelePresence System EX90
0 2698 SM-20320 Sean Miller United States Jacksonville ... 32216.0 South Technology Machines 22638.48 6 0.5 -1811.0784
145317 18 23 Class Office 10002412 Videoconferenci...
CA-2018- 2018-10- 2018-10- Standard Tamara TEC-CO- Canon imageCLASS 2200 Advanced
1 6827 TC-20980 Corporate United States Lafayette ... 47905.0 Central Technology Copiers 17499.95 5 0.0 8399.9760
118689 02 09 Class Chand 10004722 Copier
3 rows × 21 columns
In [262… Storedata.dtypes
In [265… sd.head(3)
In [267… sd.groupby("Category")[["Category"]].count()
Out[267… Category
Category
Furniture 2121
Technology 1847
In [ ]: ### instead of Grouping by, there is a function called 'unique' to find no of catagories
Out[274… 3
In [275… sd["Region"].unique()
Out[277… 826154.0329999999
Out[278… 719047.032
In [ ]: # We can't keep on doing this for every category, so we use Group by for multiple categories
In [279… sd.groupby(["Category"])[["Sales"]].sum()
Out[279… Sales
Category
Furniture 741999.7953
Technology 826154.0330
Out[280… Sales
Category Region
East 208291.2040
South 117298.6840
West 252612.7435
East 205516.0550
South 125651.3130
West 220853.2490
East 254973.9810
South 148771.9080
West 251991.8320
Out[281… Profit
Category Region
East 3046.1658
South 6771.2061
West 11504.9503
East 41014.5791
South 19986.3928
West 52609.8490
East 47462.0351
South 19991.8314
West 44303.6496
Category Region
In [ ]: # Q. Return sales, profit and quantity of goods sold for every category and region
Category Region
Category Region
# written this code because keys in the dictionary can't be repeated or there cannot be duplicate keys
# so created a list for all the aggregate functions inside the list
Out[288… Sales
Category Region
Category Region
In [294… car_data.head(3)
Out[9]: Total_Cars
Year
2003 2
2004 1
2005 4
2006 4
2007 2
2008 7
2009 6
2010 15
2011 19
2012 23
2013 33
2014 38
2015 61
2016 50
2017 35
2018 1
Out[10]: Total_Cars
Year
2015 61
2016 50
2014 38
2017 35
2013 33
2012 23
2011 19
2010 15
2008 7
2009 6
2005 4
2006 4
2003 2
2007 2
2004 1
2018 1
In [14]: type(Car1)
Out[14]: pandas.core.frame.DataFrame
In [16]: Car1.head(5)
Out[16]: Total_Cars
Year
2015 61
2016 50
2014 38
2017 35
2013 33
In [ ]: