CS 111: Program Design I
[Pages:33]CS 111: Program Design I
Lecture 15: Objects, Pandas, Modules
Robert H. Sloan & Richard Warner University of Illinois at Chicago October 13, 2016
OBJECTS AND DOT NOTATION
Objects
n (Implicit in Chapter 2, Variables, & 9.5, String Methods of book, but not explicit anywhere: So pay attention!)
n Everything in Python is an object n Object combines
q data (e.g., number, string, list) with q methods that can act on that object
Methods
n Methods: like (special case of) function but not globally accessible
n Cannot call method just by giving its name, the way we call print(), open(), abs(), type(), range(), etc.
n Method: function that can only be accessed through an object
q Using dot notation
Dot notation
n To call method, use dot notation:
q object_name.method()
n String example:
>>> test= "This is my test string" >>> test.upper() 'THIS IS MY TEST STRING'
If o is object of type having method do_it where do_it needs an input in addition to o, and x is defined, what is the proper way to call do_it?
A. do_it(x) B. do_it(o, x) C. o.do_it(x) D. o.do_it(o, x)
methods continued
>>> test.find("my") 8 >>> 42.upper() Syntax Error: invalid syntax upper(test) barf
Methods depend on type of object
n scdb.head() prints out 5 rows because head() is a method of objects of type Pandas dataframe, which is type of scdb object
n "test string".head() gives back an error because head is not a method of strings
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- cs 111 program design i
- data analytics with python
- with pandas f m a f ma vectorized a f operations cheat
- pandas
- pandas cheat sheet pandas python data analysis
- table of contents
- cheat sheet numpy python copy anasayfa
- cheat sheet pyspark sql python lei mao s log book
- data wrangling tidy data
- pandas cheat sheet pandas python data analysis library
Related searches
- cs ny employee benefits nyship
- 7 cs of communication ppt
- cs ny gov employee benefits
- 7 cs of effective communication
- the 7 cs of communication
- cs phd salary
- seven cs of communication
- project ideas for cs students
- oxford cs philosophy
- the 7 cs of communication definitions
- restore program i removed
- freud and cs lewis