Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
100%
(2)
100% found this document useful (2 votes)
238 views
11 pages
Pandas Assignment
Uploaded by
Akshay Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Pandas Assignment For Later
100%
100% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
100%
(2)
100% found this document useful (2 votes)
238 views
11 pages
Pandas Assignment
Uploaded by
Akshay Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Pandas Assignment For Later
100%
100% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
119178, 947 Pat 10,,Pandas Assignment Day 10pynd - Colaboratory Pandas Assignment Import pandas and numpy with ther aliases Create a variable 14 Seres({ 100,200,300, 400)) 2 = paasertes( 200, 308, 468)) Print, and datatype Using indexing access the element 300 from the series 2 print(atay) What ate the values of index fr series a? print(index) Printivalues) Rangerndex(starteo, stops, stapes) [ee 200 390 423) Change the index to fb] 2 = pe.sentes(( 200, 208, 300, 400), index = ("2") “2 [Access the value inthe series with index print¢at'a"]) Intps:ifeolab research google. com/érva/taFLOIVZret76aT sD 7gACRWCeNW_wuottontMode=tu an119178, 947 Pat 410,,Pandas Assignment Day 10pyno Sort the values wrt tothe index and print t assort_index(oxis = 0) ‘ype ante Create a new Pandas Series b having index as‘, and and value 800,450,100 and prit it b= pe.sentes(( 680, 459, 100), index = ("e", "€, “ely ‘Append series at the end ofa series 2 = buappendcay Sort the values in descending order of a and print he index ofthe sorted series 2 + ausort_indextonis = @) Pandas DataFrame ntps:ifeolab rosearch google. com/érvel fgFLOIVZref7aTxDTeACRWCeNW_wuottorintMod: Colaboratory at119178, 947 Pat 10,,Pandas Assignment Day 10pynd - Colaboratory Part 1 Create a pandas dataframe df from the series's' that we used in the last section print the dataframe oF = pa.vatatrane({ 209, 200, 360, 499, #90, 458, 1681) eFsne390) 100 +200 3400 Whats the shape ofthe datafarme (also, what does it imply?) oy Hey! remember shape (7,1) mplles dataframe has 7 rows and 1 column, Whats the index ofthe dataframe, ist same as the series A yep As same a5 the serses printtindex Rangelndex(starte®, stope7, stapes) print the head and tall ofthe dataframe ‘Addiional- (what does head and taliepresent?) © 100 + 200 3400 4 a0 Intps:ifeolab roscarch google. com/drva/taFLOIVZret76aTxD7eACRWCeNW_wuottorntMode=tue119123, 947 PM 10,,Pandas Assignment Day 10pynd - Colaboratory print(af.nead(2)) print(af.tati(2)) Rename the column ofthe dataframe as points f.renane(colunnss{°2": points"), inplacesTrue) 100 3400 4 800 Create another Seles ute, which contains random names of tuts from [orangemangsapple randomly selected from [orangemangoapple] fruits = (orange, "ango",‘sppte") fruits = pe.series(("orange’,"nango'y'spple']) (Change the index of futs tothe index of dataframe d fruits = pe.oatafrane({#euses* = (orange, “nango',appte"1)) ‘Add this ute series asa new column to the dataftame df with its column name as fru print the head ofthe dataframe to verity Intps:feolab roscarch google. com/érvaltgFLOIVZret76aTuD7eACRWCeNW_wuottorntMode=tue he series should contaln 7 elements, am1191723, 947 Pat 10,,Pandas Assignment Day 10pynd - Colaboratory efsneaso) Pandas Concatenation Create a datatrame di where the cols are ‘ty :['Chandigar, Deli, Kanpur, ‘Chennaf, ‘Manali ] and Temperature =[15,22, 20, 26,2] 61 = pa.vatafrane({‘esty" + ['chanaigarh', “DeInt', “Kanpur : 1 “chennat", “Manali, Temperature’ 125, 22, 28, 26,-212) Print) printean) Whats the shape of dt etty = antretty") print ity Whats the type of city prantcetty) © chandigarn Intps:ifeolab rosearch google. com/drvaltgFLOIVZret76aTsD7eACRWOeNW_wuottontMode=tu sit1191728, 947 PM 10,,Pandas Assignment Day 10pynd - Colaboratory Create another datafeame 2 where the columns are ‘ety’ -[BengalaruColmbatore!SrrangamPondichesry] Temperature’ [24353639] “Tenperature’ + [24,35,3,38]}) print the shape of this datafame 2) ‘merge the two dataames together, save in a new dataframe named'83 63 = pauconcat(fet, a2}, axis = 0) © Changer © 2 Kanpur 2» 2 Strangam 36 3 Pondchenty 38 Select the part ofthe datatrame such that it contains cities wherer temp is less then or equal to 20 How mary cities are there? naa[[ctty' Temperature’ I] {B[ Temperature” ] srry at = sil esey"|-0e8,2,3] trames Jusr/ocal/1sb/pythons.£/s8st-packages/pandas/core/indexig py in validate key_length(seif, key) 790" def validate ey length(setf, key! Sequence[y]} -> Rone Jot Ge en(eey) > sett. nai 3 1B False Indexingerror("Too many andexers") 74 def _geriven tuple_sane-din(self, taps tuple) Selecta subset ofthe dataframe dl auch that it contains the etes which only have temperature above 90 Farenhiet, ft = e9[ast tenp_tarenhiet 996] Select only the ist three rows of the dataframe dl 4 A0ef 1,233] 3 Pontchery 8 Te 1022 Select all the rows and lat wo columns inthe datarame et Aoe{t:A{ts_ut', "tonp_farenhiet* 1] Groupby 1 create 2 catafrane using tctionary of your choice cata = pd.oataFrane( ane’: ['Ankit’, ‘Aishwarya', “Shaurya!, ‘Shivangi" Ty Age’ + 123, 21, 38, 21], University’ = [°BM, "OMI", “OU, “aMU'D, 29 oF = pa.batatrane(aata, colums-{ ‘Age’ }).sun() sen) Intps:ifeolab roscarch google. com/érvaltgFLOIVZret76aTsD7gACRWCeNW_wuottontMode=tuo ont119123, 947 PM 10,,Pandas Assignment Day 10pynd - Colaboratory ige 94 type: Snes 44 Use Groupby of single colton with angregste count) (2 = data. groupby([ "University" I)[Universsty']-e2unt() Use Groupby of single column with aggregate sin() and atx() #42 = data. groupby(("Age"})-s12e().groupby (Level-8) ax) (43 = data. groupby({ "University" ]).size()-grougby(leve ning) 44 Use Groupby of any 2 columns with a nea) (2 = data-groupby( ("Age") 988((°Age"* 'ne80"1)) ef2.colunms = [-abr_sean"] na nm m0 2» m0 Use Grouply of any 2 colums with aggregate sin() and max() 22's data. groupby( (Age, Mare" I).agg(Cage"? [nin "mae ]},(°Mave's (nin’, “aa D)) ef2.colums = ("age nin", "age sax stage ierst ag Page Covers min’, Snare ))oCAg8" Cain's mae) oniversity Age a) Data Range Create a pandas daterange where starting date is Tst of January.2020 and end dates 1st of April 2021, store it na new variable named’ 8 = pe.date_range(sta 2020-61-81", endo'2621-01-1") pinta Datetinerndex({'2022-01-01', "2020-01-02", "2020-01-05", "2020-01-64", Intps:ifeolab roscarch google. com/érvaltgFLOIVZret76aTsD7gACRWCeNW_wuottontMode=tuo sont119178, 947 Pat 10,,Pandas Assignment Day 10pynd - Colaboratory types‘datetinesa{ns]", lengthea57, freq'2") Whats the len of a? tents) Whats the ype ofa? eyeeta) Intps:ifeolab roscarch google. com/érvaltgFLOIVZret76aTsD7gACRWCeNW_wuottontMode=tuo wt
You might also like
Life Expectancy Data
PDF
No ratings yet
Life Expectancy Data
288 pages
Car Details From Car Dekho
PDF
No ratings yet
Car Details From Car Dekho
212 pages
Python Complete Material Notes by Ns
PDF
No ratings yet
Python Complete Material Notes by Ns
348 pages
Statistics Assignemt
PDF
100% (1)
Statistics Assignemt
19 pages
Pandas Class XII (2021-22)
PDF
No ratings yet
Pandas Class XII (2021-22)
246 pages
EDA Assignment
PDF
No ratings yet
EDA Assignment
16 pages
1-PPS Python Lab Manual CSEL202
PDF
No ratings yet
1-PPS Python Lab Manual CSEL202
86 pages
Zivame Planning Analyst Excel SQL Test
PDF
No ratings yet
Zivame Planning Analyst Excel SQL Test
50 pages
10 Min Pandas
PDF
No ratings yet
10 Min Pandas
18 pages
New - SQL Qustions
PDF
No ratings yet
New - SQL Qustions
3 pages
Untitled Spreadsheet
PDF
No ratings yet
Untitled Spreadsheet
3 pages
Linear Reg 1
PDF
No ratings yet
Linear Reg 1
7 pages
Unit II Visualizing Using Matplotlib
PDF
No ratings yet
Unit II Visualizing Using Matplotlib
24 pages
Top 50 Pandas Interview Questions and Answers (2024)
PDF
No ratings yet
Top 50 Pandas Interview Questions and Answers (2024)
34 pages
Ad3301 Dev Full Notes
PDF
No ratings yet
Ad3301 Dev Full Notes
53 pages
Advanced Python
PDF
No ratings yet
Advanced Python
204 pages
Python Data Structure Assignment
PDF
No ratings yet
Python Data Structure Assignment
9 pages
Lab3 - Python - Pandas DataFrame - GeeksforGeeks
PDF
No ratings yet
Lab3 - Python - Pandas DataFrame - GeeksforGeeks
20 pages
Data Analysis and Visualisation With Python
PDF
No ratings yet
Data Analysis and Visualisation With Python
75 pages
Unit 1
PDF
100% (1)
Unit 1
69 pages
Unit 4
PDF
No ratings yet
Unit 4
60 pages
Ge3171 Pplab
PDF
No ratings yet
Ge3171 Pplab
63 pages
Chapter 4 File Handlinf Final (New)
PDF
No ratings yet
Chapter 4 File Handlinf Final (New)
78 pages
w3school numpy
PDF
No ratings yet
w3school numpy
9 pages
DS Unit 3 Part 1
PDF
No ratings yet
DS Unit 3 Part 1
27 pages
Python With Data Science
PDF
No ratings yet
Python With Data Science
102 pages
Image Processing and Pattern Recoginition Lab Manual
PDF
No ratings yet
Image Processing and Pattern Recoginition Lab Manual
38 pages
Pandas Notes
PDF
No ratings yet
Pandas Notes
4 pages
Unit 4 Fod
PDF
100% (1)
Unit 4 Fod
21 pages
Assignment 61
PDF
100% (2)
Assignment 61
4 pages
Project
PDF
No ratings yet
Project
18 pages
Python Function Questions
PDF
No ratings yet
Python Function Questions
13 pages
Dictionaries in Python
PDF
No ratings yet
Dictionaries in Python
21 pages
Pandas Dataframe
PDF
No ratings yet
Pandas Dataframe
48 pages
Tableau Lab Manual
PDF
No ratings yet
Tableau Lab Manual
6 pages
Python Revision Tour-2 Worksheet
PDF
No ratings yet
Python Revision Tour-2 Worksheet
8 pages
Python Syllabus
PDF
100% (1)
Python Syllabus
4 pages
Sets in Python
PDF
No ratings yet
Sets in Python
7 pages
03 Strings in Python
PDF
No ratings yet
03 Strings in Python
29 pages
Bca-Iv Sem Dar Imp Questions
PDF
100% (1)
Bca-Iv Sem Dar Imp Questions
1 page
Python Record
PDF
No ratings yet
Python Record
35 pages
13.file Handling
PDF
No ratings yet
13.file Handling
66 pages
Block 1-Data Handling Using Pandas DataFrame
PDF
No ratings yet
Block 1-Data Handling Using Pandas DataFrame
17 pages
Pandas in Python 16sept2022
PDF
No ratings yet
Pandas in Python 16sept2022
8 pages
Assignment 2 Oops
PDF
No ratings yet
Assignment 2 Oops
10 pages
Car Data
PDF
No ratings yet
Car Data
16 pages
FDS Lab Manual
PDF
No ratings yet
FDS Lab Manual
48 pages
Python Programming - Introduction All
PDF
No ratings yet
Python Programming - Introduction All
44 pages
Python Programming Lab Manual
PDF
No ratings yet
Python Programming Lab Manual
14 pages
NumPy Notes
PDF
No ratings yet
NumPy Notes
13 pages
Assignment Dict For Python
PDF
No ratings yet
Assignment Dict For Python
6 pages
Tuple in Python PDF
PDF
No ratings yet
Tuple in Python PDF
20 pages
Pandas Dataframe Assignment No 3 - Answerkey
PDF
No ratings yet
Pandas Dataframe Assignment No 3 - Answerkey
10 pages
Numpy - Tutorial - Ipynb - Colaboratory
PDF
No ratings yet
Numpy - Tutorial - Ipynb - Colaboratory
9 pages
4 Exploratory Data Analysis.
PDF
No ratings yet
4 Exploratory Data Analysis.
1 page
Ge8151 Phython Prog Unit 4 New
PDF
No ratings yet
Ge8151 Phython Prog Unit 4 New
33 pages
Artificial Intelligence Lab Manual: Python
PDF
No ratings yet
Artificial Intelligence Lab Manual: Python
15 pages
Python MCQ-10 (Ques)
PDF
No ratings yet
Python MCQ-10 (Ques)
2 pages
Unit 1 Python
PDF
No ratings yet
Unit 1 Python
52 pages
Python Study Material
PDF
No ratings yet
Python Study Material
11 pages
Programming For Data Science With Python: Nanodegree Program Syllabus
PDF
No ratings yet
Programming For Data Science With Python: Nanodegree Program Syllabus
13 pages
Python Assignment
PDF
No ratings yet
Python Assignment
7 pages
Lab Assignment Questions of Python
PDF
100% (1)
Lab Assignment Questions of Python
2 pages
MCQ Questions
PDF
No ratings yet
MCQ Questions
8 pages
SL Important Questions
PDF
No ratings yet
SL Important Questions
3 pages
Python File 1-9
PDF
No ratings yet
Python File 1-9
11 pages
Unit - 1 1.what Are The Features of Python. Explain The PVM. Ans: Following Are Some Important Features of Python
PDF
No ratings yet
Unit - 1 1.what Are The Features of Python. Explain The PVM. Ans: Following Are Some Important Features of Python
15 pages
CIA I Answer Key
PDF
No ratings yet
CIA I Answer Key
8 pages
Syllabus GE3151 PROBLEM SOLVING AND PYTHON PROGRAMMING 3 0 0 3
PDF
No ratings yet
Syllabus GE3151 PROBLEM SOLVING AND PYTHON PROGRAMMING 3 0 0 3
2 pages