DataFrames with Conditionals


The use of conditionals allows us to select a subset of rows based on the value in each row. Writing a conditional to select rows based on the data in a single column is straightforward and was used when we selected all of the courses taught by the Statistics department with the following code:

Both cells return the exact same output:
df[ df.Subject == "STAT" ]     # dot notation, using df.Subject
df[ df["Subject"] == "STAT" ]  # index notation, using df["Subject"]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
80022019Fall2019-faSTAT100StatisticsFirst course in probability and statistics at ...3 hours.Credit is not given for both STAT 100 and any ...Quantitative Reasoning I course.
80032019Fall2019-faSTAT107Data Science DiscoveryData Science Discovery is the intersection of ...4 hours.Same as CS 107 and IS 107.Quantitative Reasoning I course.
80042019Fall2019-faSTAT199Undergraduate Open SeminarSee course schedule for topics. Approved for L...1 TO 5 hours.NaNNaN
80052019Fall2019-faSTAT200Statistical AnalysisSurvey of statistical concepts, data analysis,...3 hours.Credit is not given for both STAT 200 and STAT...Quantitative Reasoning I course.
80062019Fall2019-faSTAT212BiostatisticsApplication of statistical reasoning and stati...3 hours.Credit is not given for both STAT 212 and STAT...Quantitative Reasoning I course.
80072019Fall2019-faSTAT361Probability & Statistics for Computer ScienceSame as CS 361. See CS 361.3 hours.Same as CS 361. See CS 361.NaN
80082019Fall2019-faSTAT385Statistics Programming MethodsStatisticians must be savvy in programming met...3 hours.Prerequisite: STAT 200 or STAT 212.NaN
80092019Fall2019-faSTAT390Individual StudyMay be repeated to a maximum of 8 hours. Prere...1 OR 2 hours.May be repeated to a maximum of 8 hours. Prere...NaN
80102019Fall2019-faSTAT391Honors Individual StudyMay be repeated to a maximum of 8 hours. Prere...1 OR 2 hours.May be repeated to a maximum of 8 hours. Prere...NaN
80112019Fall2019-faSTAT400Statistics and Probability IIntroduction to mathematical statistics that d...4 hours.Same as MATH 463. 4 undergraduate hours. 4 gra...NaN
80122019Fall2019-faSTAT408Actuarial Statistics IExamines elementary theory of probability, inc...4 hours.NaNNaN
80132019Fall2019-faSTAT409Actuarial Statistics IIContinuation of STAT 408. Examines parametric ...4 hours.Same as ASRM 402. 4 undergraduate hours. 4 gra...NaN
80142019Fall2019-faSTAT410Statistics and Probability IIContinuation of STAT 400. Includes moment-gene...3 OR 4 hours.Same as MATH 464. 3 undergraduate hours. 4 gra...NaN
80152019Fall2019-faSTAT420Methods of Applied StatisticsSystematic, calculus-based coverage of the mor...3 OR 4 hours.Same as ASRM 450. 3 undergraduate hours. 4 gra...NaN
80162019Fall2019-faSTAT424Analysis of VarianceEstimation and hypotheses testing in linear mo...3 OR 4 hours.NaNNaN
80172019Fall2019-faSTAT425Applied Regression and DesignExplores linear regression, least squares esti...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. Prere...NaN
80182019Fall2019-faSTAT426Sampling and Categorical DataSampling: simple random, stratified, systemati...3 OR 4 hours.NaNNaN
80192019Fall2019-faSTAT427Statistical ConsultingStudents, working in groups under the supervis...3 OR 4 hours.NaNNaN
80202019Fall2019-faSTAT428Statistical ComputingExamines statistical packages, numerical analy...3 OR 4 hours.Same as CSE 428. 3 undergraduate hours. 4 grad...NaN
80212019Fall2019-faSTAT429Time Series AnalysisStudies theory and data analysis for time seri...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. Prere...NaN
80222019Fall2019-faSTAT430Topics in Applied StatisticsFormulation and analysis of mathematical model...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. May b...NaN
80232019Fall2019-faSTAT431Applied Bayesian AnalysisIntroduction to the concepts and methodology o...3 OR 4 hours.NaNNaN
80242019Fall2019-faSTAT432Basics of Statistical LearningTopics in supervised and unsupervised learning...3 OR 4 hours.Same as ASRM 451. 3 undergraduate hours. 4 gra...NaN
80252019Fall2019-faSTAT433Stochastic ProcessesA stochastic process is a random process that ...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. Prere...NaN
80262019Fall2019-faSTAT434Survival AnalysisIntroduction to the analysis of time-to-event ...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. Prere...NaN
80272019Fall2019-faSTAT440Statistical Data ManagementThe critical elements of data storage, data cl...3 OR 4 hours.Same as CSE 440. 3 undergraduate hours. 4 grad...NaN
80282019Fall2019-faSTAT443Professional StatisticsThis project-based course emphasizes written, ...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. Prere...NaN
80292019Fall2019-faSTAT448Advanced Data AnalysisSeveral of the most widely used techniques of ...4 hours.Same as CSE 448. 4 undergraduate hours. 4 grad...NaN
80302019Fall2019-faSTAT458Math Modeling in Life SciencesSame as ANSC 448 and IB 487. See ANSC 448.3 OR 4 hours.NaNNaN
80312019Fall2019-faSTAT480Data Science FoundationsExamines the methods of data management and an...3 OR 4 hours.3 undergraduate hours. 4 graduate hours. Prere...NaN
80322019Fall2019-faSTAT510Mathematical Statistics IDistributions, transformations, order-statisti...4 hours.Prerequisite: STAT 410.NaN
80332019Fall2019-faSTAT511Mathematical Statistics IIBayes estimates, minimaxity, admissibility; ma...4 hours.NaNNaN
80342019Fall2019-faSTAT525Computational StatisticsVarious topics, such as ridge regression; robu...4 hours.NaNNaN
80352019Fall2019-faSTAT527Advanced Regression AnalysisAn advanced introduction to regression analysi...4 hours.4 graduate hours. No professional credit. Prer...NaN
80362019Fall2019-faSTAT530BioinformaticsSame as ANSC 543, CHBE 571, and MCB 571. See C...4 hours.NaNNaN
80372019Fall2019-faSTAT534Advanced Survival AnalysisIntroduction to the analysis of time-to-event ...4 hours.NaNNaN
80382019Fall2019-faSTAT538Clinical Trials MethodologyThe topics of the course focus on clinical tri...4 hours.NaNNaN
80392019Fall2019-faSTAT541Predictive AnalyticsSame as ASRM 552. See ASRM 552.4 hours.NaNNaN
80402019Fall2019-faSTAT542Statistical LearningModern techniques of predictive modeling, clas...4 hours.Same as ASRM 551 and CSE 542. 4 graduate hours...NaN
80412019Fall2019-faSTAT543Appl. Multivariate StatisticsSame as CPSC 543. See CPSC 543.4 hours.NaNNaN
80422019Fall2019-faSTAT545Spatial StatisticsTheory and methods for analyzing univariate an...4 hours.NaNNaN
80432019Fall2019-faSTAT546Machine Learning in Data ScienceTrains students to analyze large complex data ...4 hours.NaNNaN
80442019Fall2019-faSTAT551Theory of Probability ISame as MATH 561. See MATH 561.4 hours.NaNNaN
80452019Fall2019-faSTAT552Theory of Probability IISame as MATH 562. See MATH 562.4 hours.Same as MATH 562. See MATH 562.NaN
80462019Fall2019-faSTAT553Probability and Measure IMeasures and probabilities; integration and ex...4 hours.Prerequisite: MATH 447 or consent of instructor.NaN
80472019Fall2019-faSTAT554Probability and Measure IIMeasure extensions, Lebesque-Stieltjes measure...4 hours.NaNNaN
80482019Fall2019-faSTAT555Applied Stochastic ProcessesSame as MATH 564. See MATH 564.4 hours.Same as MATH 564. See MATH 564.NaN
80492019Fall2019-faSTAT558Risk Modeling and AnalysisSame as MATH 563. See MATH 563.4 hours.Same as MATH 563. See MATH 563.NaN
80502019Fall2019-faSTAT571Multivariate AnalysisInference in multivariate statistical populati...4 hours.Prerequisite: STAT 410 and MATH 415, or consen...NaN
80512019Fall2019-faSTAT575Large Sample TheoryLimiting distribution of maximum likelihood es...4 hours.NaNNaN
80522019Fall2019-faSTAT578Topics in StatisticsMay be repeated if topics vary. Prerequisite: ...4 hours.May be repeated if topics vary. Prerequisite: ...NaN
80532019Fall2019-faSTAT587Hierarchical Linear ModelsSame as PSYC 587 and EPSY 587. See EPSY 587.4 hours.NaNNaN
80542019Fall2019-faSTAT588Covar Struct and Factor ModelsSame as EPSY 588, PSYC 588, and SOC 588. See P...4 hours.NaNNaN
80552019Fall2019-faSTAT590Individual Study and ResearchDirected reading and research. Approved for le...0 TO 8 hours.Approved for letter and S/U grading. May be re...NaN
80562019Fall2019-faSTAT593STAT InternshipSupervised, off-campus experience in a field i...0 TO 8 hours.Approved for letter and S/U grading. Prerequis...NaN
80572019Fall2019-faSTAT595Preparing Future FacultyPrepares Ph.D. students who are interested in ...2 hours.NaNNaN
80582019Fall2019-faSTAT599Thesis ResearchApproved for S/U grading only. May be repeated...0 TO 16 hours.Approved for S/U grading only. May be repeated...NaN

The subset of rows where the Subject is exactly equal to STAT (57 rows).

Complex Conditionals with Multiple Parts

As we want to answer more complex questions, we need increasingly complex conditionals. To help understand how a computer works, you may be familiar with the idea that computers ultimately only think in zeros and ones:

  • When a computer stores a zero, we consider that to be False.
  • When a computer stores a one, we consider that to be True.

When we use conditionals, we are assigning a truth value to every single row in the DataFrame.

  • With our conditional df[df.Subject == "STAT"], all rows where the Subject data was "STAT" was assigned a truth value of True and kept in the final result; all other rows were labeled False and discarded.

All programming languages allows us to combine conditionals together in two key ways: with an AND (&) or with an OR (|).

Multiple Conditionals Joined with AND (&)

When we combine two conditionals, we can ask Python to keep only the result where the first conditional AND the second conditional are both True.

Writing a conditional with multiple parts requires the use of parenthesis around each individual conditional and an operation joining the two conditionals together. For example, using the Course Catalog dataset, we want all of the courses that are taught by Computer Science (CS) with a course number less than 300:

df[ (df.Subject == "CS") & (df.Number < 300) ]
# [ (First Conditional) AND (Second Conditional) ]

Both the first (Subject is exactly equal to "CS") and second (Number is less than 300) conditionals are checked independently. Since an AND (&) is used to join these two conditionals, the final truth value is True only when both conditionals are True:

df[ (df.Subject == "CS") & (df.Number < 300) ]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
23102019Fall2019-faCS100Freshman OrientationIntroduction to Computer Science as a field an...1 hours.NaNNaN
23112019Fall2019-faCS101Intro Computing: Engrg &amp; SciFundamental principles, concepts, and methods ...3 hours.Prerequisite: MATH 220 or MATH 221.Quantitative Reasoning II course.
23122019Fall2019-faCS102Little Bits to Big IdeasSame as INFO 102. See INFO 102.4 hours.NaNNaN
23132019Fall2019-faCS105Intro Computing: Non-TechComputing as an essential tool of academic and...3 hours.Prerequisite: MATH 112.Quantitative Reasoning I course.
23142019Fall2019-faCS107Data Science DiscoverySame as IS 107 and STAT 107. See STAT 107.4 hours.Same as IS 107 and STAT 107. See STAT 107.Quantitative Reasoning I course.
23152019Fall2019-faCS125Intro to Computer ScienceBasic concepts in computing and fundamental te...4 hours.Prerequisite: Three years of high school mathe...Quantitative Reasoning I course.
23162019Fall2019-faCS126Software Design StudioFundamental principles and techniques of softw...3 hours.Credit is not given for both CS 242 and CS 126...NaN
23172019Fall2019-faCS173Discrete StructuresDiscrete mathematical structures frequently en...3 hours.Credit is not given for both CS 173 and MATH 2...NaN
23182019Fall2019-faCS196Freshman HonorsOffered for honors credit in conjunction with ...1 hours.May be repeated. Prerequisite: Concurrent regi...NaN
23192019Fall2019-faCS199Undergraduate Open Seminar in Computer ScienceTopics vary. Approved for Letter and S/U gradi...0 TO 5 hours.Approved for Letter and S/U grading. May be re...NaN
23202019Fall2019-faCS210Ethical &amp; Professional IssuesEthics for the computing profession. Ethical d...2 hours.Credit is not given for both CS 210 and ECE 31...NaN
23212019Fall2019-faCS225Data StructuresData abstractions: elementary data structures ...4 hours.Prerequisite: CS 125 or ECE 220; CS 173 or MAT...Quantitative Reasoning II course.
23222019Fall2019-faCS233Computer ArchitectureFundamentals of computer architecture: digital...4 hours.Prerequisite: CS 125 and CS 173; credit or con...NaN
23232019Fall2019-faCS240Introduction to Computer SystemsBasics of computer systems. Number representat...3 hours.NaNNaN
23242019Fall2019-faCS241System ProgrammingBasics of system programming, including POSIX ...4 hours.Credit is not given for both CS 241 and ECE 39...NaN
23252019Fall2019-faCS242Programming StudioIntensive programming lab intended to strength...3 hours.Prerequisite: CS 241.NaN
23262019Fall2019-faCS296Honors CourseGroup projects for honors credit in computer s...1 hours.May be repeated. Prerequisite: Concurrent regi...NaN

All CS courses with course numbers less than 300 (17 rows).

Python allows us to continue to apply conditionals together infinitely long -- so it's no problem to have three conditionals:

df[ (df.Subject == "CS") & (df.Number < 300) & (df["Credit Hours"] == "3 hours.") ]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
23112019Fall2019-faCS101Intro Computing: Engrg &amp; SciFundamental principles, concepts, and methods ...3 hours.Prerequisite: MATH 220 or MATH 221.Quantitative Reasoning II course.
23132019Fall2019-faCS105Intro Computing: Non-TechComputing as an essential tool of academic and...3 hours.Prerequisite: MATH 112.Quantitative Reasoning I course.
23162019Fall2019-faCS126Software Design StudioFundamental principles and techniques of softw...3 hours.Credit is not given for both CS 242 and CS 126...NaN
23172019Fall2019-faCS173Discrete StructuresDiscrete mathematical structures frequently en...3 hours.Credit is not given for both CS 173 and MATH 2...NaN
23232019Fall2019-faCS240Introduction to Computer SystemsBasics of computer systems. Number representat...3 hours.NaNNaN
23252019Fall2019-faCS242Programming StudioIntensive programming lab intended to strength...3 hours.Prerequisite: CS 241.NaN

All CS courses with course numbers less than 300 and exactly 3 credit hours (6 rows).

Multiple Conditionals Joined with OR (|)

Alternatively, Python can combine two conditionals together and keep the result when either the first conditional OR the second conditional is True (this includes when they're both True as well!). There are two major applications when this is useful:

  1. Selecting multiple values of data from the same column (ex: all courses in "ARTD" OR "ARTE" OR "ARTF").
  2. Selecting multiple values from different columns and keeping all matches (ex: all courses in "PSYC" OR courses that are only 1 credit hour).

Selecting Multiple Values of Data from the Same Column

Looking at the first example above, the University of Illinois has a lot of courses in art across many different sub-areas of art including: Art Design ("ARTD"), Art Education ("ARTE"), Art Foundation ("ARTF"), Art History ("ARTH"), and Art Studio ("ARTS").

To include ALL courses from all five sub-areas of art listed above, we must join them together with an OR (|). Notice that it is necessary to specify each conditional completely each time even though we are always comparing the subject since Python has to evaluate each conditional independently and then combine the results together:

df[ (df.Subject == "ARTD") | (df.Subject == "ARTE") | (df.Subject == "ARTF") | (df.Subject == "ARTH") | (df.Subject == "ARTS") ]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
10042019Fall2019-faARTD101Introduction to Industrial DesignIntroduction to problem-finding and problem-so...3 hours.Additional fees may apply. See Class Schedule....NaN
10052019Fall2019-faARTD151Introduction to Graphic DesignAn introductory course for students considerin...3 hours.Additional fees may apply. See Class Schedule....NaN
10062019Fall2019-faARTD160The Image WorldExplores photography and video as the most pow...3 hours.Additional fees may apply. See Class Schedule....NaN
10072019Fall2019-faARTD201Industrial Design IIntroduction to the creative process and metho...4 hours.Additional fees may apply. See Class Schedule....NaN
10082019Fall2019-faARTD202Industrial Design IIStudio design problems of increasing complexit...4 hours.NaNNaN
.................................
12202019Fall2019-faARTS490Senior HonorsIndependent creative activity, guided study, o...2 TO 5 hours.2 to 5 undergraduate hours. No graduate credit...NaN
12212019Fall2019-faARTS499Special Topics in Studio ArtSpecial topics in studio arts. Topics and subj...1 to 4 hours.NaNNaN
12222019Fall2019-faARTS591Graduate StudioDirected individual creative activity or resea...1 TO 8 hours.Additional fees may apply. See Class Schedule....NaN
12232019Fall2019-faARTS593Seminar: Methods CriticismPrerequisite: Graduate standing in art.1 TO 4 hours.Prerequisite: Graduate standing in art.NaN
12242019Fall2019-faARTS595Graduate LaboratoryIndividually directed research and personal. A...4 TO 12 hours.Additional fees may apply. See Class Schedule....NaN

All courses in any subjects ARTD, ARTE, ARTF, ARTH, OR ARTS (221 rows).

Selecting Multiple Values from Different Columns and Keeping All Matches

To be considered a "full-time student" at most universities, you must be enrolled in at least 12 credit hours. If you are only enrolled in 11 credit hours, you may be interested in any course that will bump you up to exactly 12 credit hours (ex: a course worth exactly one credit hour) or a course you may be interested in (ex: something from the psychology ("PSYC") department).

To include ALL of the results of all courses that are either one credit hour OR in the psychology department, we need an OR:

df[ (df["Credit Hours"] == "1 hours.") | (df["Subject"] == "PSYC") ]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
492019Fall2019-faABE100Intro Agric &amp; Biological EngrgIntroduction to the engineering profession wit...1 hours.NaNNaN
832019Fall2019-faABE501Graduate Research IBasic research orientation, research methods, ...1 hours.NaNNaN
842019Fall2019-faABE502Graduate Research IIResearch methodology, teaching methods, lectur...1 hours.NaNNaN
2292019Fall2019-faACE569Career Development for PhDsThis course is intendedto help doctoral candid...1 hours.Approved for S/U grading only. Prerequisite: A...NaN
2452019Fall2019-faACES399Honors SeminarDesigned to promote exposure to, and subsequen...1 hours.NaNNaN
.................................
85592019Fall2019-faVM626The Basics of BusinessBusiness principles related to managing a vete...1 hours.1 graduate hour. 1 professional hour. Prerequi...NaN
85602019Fall2019-faVM627Fundamentals of FinanceProvides students with a strong introductory b...1 hours.NaNNaN
85622019Fall2019-faVM642Contemporary Issues in Vet MedAn introductory course for first year veterina...1 hours.NaNNaN
85632019Fall2019-faVM643Fundamentals of ManagementAn introductory course for second year veterin...1 hours.No graduate credit. 1 professional hour. Appro...NaN
85642019Fall2019-faVM645Communications in PracticeAn introductory course for third year veterina...1 hours.NaNNaN

All courses that are exactly one credit hour OR in the psychology department (490 rows).

Combining ANDs and ORs

The most complex conditionals will require a combination of both AND and OR statements. These can get incredibly tricky, but we can remember that Python will always process conditionals by only combining two conditionals together at a time.

Since Python combines only two conditionals together at any given time, it is critical we use parenthesis to ensure we specify the order that we want these conditionals combined. For example, let's explore only junior level (300-399) courses in Chemistry or Physics. To do so:

  • The subject of the course must be CHEM or PHYS.
  • The course number must be greater than or equal to 300.
  • The course number must also be less than 400.

Naively writing this conditional results in the following code:

df[ (df.Subject == "CHEM") | (df.Subject == "PHYS") & (df.Number >= 300) & (df.Number < 400) ]

Default Order of Evaluation: AND before OR

If we do not use additional parenthesis, Python will always combine the ANDs first and then the ORs and will do so in left-to-right order. This means that:

  1. The first set of two conditionals combined will be the first AND conditional: (df.Subject == "PHYS") & (df.Number >= 300). The result contains all courses in PHYS with a number larger than 300.

  2. The second set of two conditionals will be the result from #1 with the second AND: (Result of Step #1) & (df.Number < 400). The result contains all courses in PHYS with a number from 300-399.

  3. The final set of conditionals will be combined using OR: (df.Subject == "CHEM") | (Result of Step #2). Since this is an OR, the result is ALL CHEM courses and then only the PHYS courses in the number 300-399.

We can verify our result by running the code:

df[ (df.Subject == "CHEM") | (df.Subject == "PHYS") & (df.Number >= 300) & (df.Number < 400) ]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
18722019Fall2019-faCHEM312Inorganic ChemistryBasic chemical bonding in molecules, introduct...3 hours.Prerequisite: CHEM 232 or CHEM 236.NaN
18732019Fall2019-faCHEM315Instrumental Chem Systems LabLaboratory course emphasizes the application o...2 hours.Prerequisite: Either CHEM 237 or both CHEM 223...NaN
18742019Fall2019-faCHEM317Inorganic Chemistry LabEmphasizes modern techniques for the synthesis...3 hours.NaNAdvanced Composition course.
18752019Fall2019-faCHEM332Elementary Organic Chem IIContinuation of CHEM 232 focuses on organic ch...4 hours.Credit is not given for both CHEM 332 and CHEM...NaN
18762019Fall2019-faCHEM360Chemistry of the EnvironmentStudy of the chemistry of the atmosphere, the ...3 hours.NaNNaN
.................................
68592019Fall2019-faPHYS583Advanced Field TheoryQuantization and Feynman path integral; gauge ...4 hours.NaNNaN
68602019Fall2019-faPHYS596Graduate Physics OrientationIntroduction to research in the Department of ...1 hours.NaNNaN
68612019Fall2019-faPHYS597Individual StudyIndividual study in a subject not covered in c...1 TO 16 hours.May be repeated. 2 to 16 hours for full term; ...NaN
68622019Fall2019-faPHYS598Special Topics in PhysicsSubject offerings of new and developing areas ...1 TO 4 hours.May be repeated in the same or separate terms ...NaN
68632019Fall2019-faPHYS599Thesis ResearchApproved for S/U grading only. May be repeated.0 TO 16 hours.Approved for S/U grading only. May be repeated.NaN

The output of incorrect logic that does use parenthesis, which includes 500-level PHYS courses (92 rows).

Notice that the code appears correct until we scroll down! The courses in Chemistry start at 300, but the last five rows show us that the courses in Physics include 500-level courses -- yikes!

Order of Evaluation: Using Parenthesis to Specify Order

Python uses parenthesis in a similar way to basic mathematics where the inner-most operations are done first. In our example, we want to make sure that all Chemistry and Physics courses are combined first, and only then can we limit the range of course numbers to the junior level.

By grouping both of these logical operations together, our new conditional can be thought of as a combination of two complex conditionals:

  1. (df.Subject == "CHEM") | (df.Subject == "PHYS"), selecting only that are Chemistry OR Physics

  2. (df.Number >= 300) & (df.Number < 400), selecting only courses between 300 AND 399.

Joining these two conditionals together with an AND results in the exact output we expect:

df[ ((df.Subject == "CHEM") | (df.Subject == "PHYS")) & ((df.Number >= 300) & (df.Number < 400)) ]
YearTermYearTermSubjectNumberNameDescriptionCredit HoursSection InfoDegree Attributes
18722019Fall2019-faCHEM312Inorganic ChemistryBasic chemical bonding in molecules, introduct...3 hours.Prerequisite: CHEM 232 or CHEM 236.NaN
18732019Fall2019-faCHEM315Instrumental Chem Systems LabLaboratory course emphasizes the application o...2 hours.Prerequisite: Either CHEM 237 or both CHEM 223...NaN
18742019Fall2019-faCHEM317Inorganic Chemistry LabEmphasizes modern techniques for the synthesis...3 hours.NaNAdvanced Composition course.
18752019Fall2019-faCHEM332Elementary Organic Chem IIContinuation of CHEM 232 focuses on organic ch...4 hours.Credit is not given for both CHEM 332 and CHEM...NaN
18762019Fall2019-faCHEM360Chemistry of the EnvironmentStudy of the chemistry of the atmosphere, the ...3 hours.NaNNaN
18772019Fall2019-faCHEM397Individual Study JuniorIndividual study of problems related to chemis...1 TO 3 hours.May be repeated in separate terms. A maximum o...NaN
68072019Fall2019-faPHYS325Classical Mechanics IKinematics and dynamics of classical systems, ...3 hours.Prerequisite: PHYS 225; credit or concurrent r...NaN
68082019Fall2019-faPHYS326Classical Mechanics IIContinuation of PHYS 325. Central force motion...3 hours.Prerequisite: PHYS 325.NaN
68092019Fall2019-faPHYS329Atmospheric Dynamics ISame as ATMS 302. See ATMS 302.3 hours.Same as ATMS 302. See ATMS 302.NaN
68102019Fall2019-faPHYS330Atmospheric Dynamics IISame as ATMS 312. See ATMS 312.3 hours.NaNNaN
68112019Fall2019-faPHYS398Sophomore/Junior Special Topics in PhysicsTopical offerings of technical interest, skill...1 TO 4 hours.Approved for Letter and S/U grading. May be re...NaN

All 300-level courses in chemistry or physics (11 rows).


Example Walk-Throughs with Worksheets

Video 1: DataFrame Conditionals using The Party Dataset

Follow along with the worksheet to work through the problem:

Video 2: DataFrame Conditionals using The Berkeley Dataset

Follow along with the worksheet to work through the problem:

Video 3: DataFrame Conditionals using The Course Catalog Dataset

Follow along with the worksheet to work through the problem:

Practice Questions

Q1: How would you subset a DataFrame titled "restaurants" with columns "food_type" and "location" to only show pizza places in Urbana using Python?
Q2: What best describes what rows are being selected by this conditional statement: movies[ (movies.genre == "Horror") | (movies.genre == "Action") & (movies.rating >= 90) ]
Q3: How would you fix the following code that is attempting to selet all STAT and CS courses that are 3 credit hours and level 200 or higher?
Q4: Which of the following would NOT be a situation where you would want to use the OR (|) conditional in Python?
Q5: Which conditional operation in Python would you want to use if you're selecting multiple values of data from the same column?