Python Comprehensive Final & Tableau

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/64

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

65 Terms

1
New cards

F-string

print (f “I have this many {variable}.”)

2
New cards

String concatenation

print (“I understand how to + variable + fish at a specific temperature of + variable2 + “.” ”)

Combines strings with an operator like + (plus) , (comma) % (remainder)

3
New cards

if statements

allows you to make decisions on certain conditions through programming

if age >= 21:

print (“You can have a drink!”)

4
New cards

elif

else if; takes consideration of other decisions or numbers

if age == 21:

print (“You can have a drink!”)

elif age > 21:

print(“Oh yeah! You can definitely have a drink!”)

5
New cards

else

means that if all conditions were not met or not true; this considers all other factors that are not true

if age == 21:

print (“You can have a drink!”)

elif age > 21:

print (“Oh yeah! You can have a drink!”)

else:

print (“Have a glass of water.”)

6
New cards

+

addition

7
New cards

-

subtraction

8
New cards

*

multiplication

9
New cards

/

division

10
New cards

**

power

11
New cards

%

remainder

12
New cards

cast

when you take a function and cover it with another function outward

int(input(“What is your favorite number?”))

13
New cards

.upper()

make it upper case; CHANGE is PERMANENT

14
New cards

.lower()

CHANGE the name to lower case; no permanent

15
New cards

.title()

updates the name in proper form

16
New cards

.replace()

replaces values or update the values

.replace(“I”, ““)

17
New cards

.partition()

divides the strings into 3 separate parts based on a specific separator

name = “Franklin D. Roosevelt”

separateNames = name.replace()

output:

(“Franklin”, ““ “D. Roosevelt”)

18
New cards

.split()

splits a string into a list of strings after breaking the given string by a specified separator

name = "roseanne chaeyoung park”

separateName = name.split()

output

[“roseanne” “chaeyoung” “park”]

19
New cards

.strip()

strips unnecessary space

20
New cards

index

counts from zero to how many digits a character signifies

CHEESE = 0, 1, 2, 3, 4, 5 (in total would be 6 digits)

21
New cards

Tuples

Purpose: Collection of values

Special/Unique: cannot be modified; only read

Defined by: () —> parentheses

name_tuple = (“Jinsoul”, ““, “Kim”) —> index of 3

22
New cards

Loop

repeats the same action or sequence multiple times; requires an iterator/counter;

for each_name in name_tuple

print(each_name) - indented

print(“Stan Loona”) - indented

print(“Loop by Yves SOTY”)

23
New cards

List

Purpose: collection of values

Special: can be CHANGED

Defined: Squared Brackets []

24
New cards

.append()

Special to lists; adds to a list as a new value

25
New cards

.merge()

Given if there is another list to add to another —> list2.merge(list1)

26
New cards

.pop()

uses an index to remove something —> list1.pop(4) — pops the value holder of 4

27
New cards

.clear()

removes the list in its entirety

28
New cards

Sets

Purpose: collection of values/data

Unique: Does not allow for duplicates/all values have to be unique

Defined by: {} curly braces

29
New cards

.add()

Special to sets

adds another value to the set; but has to be a different value

30
New cards

.union()

two lists are asked to be combined; it does combine them and any duplicates are listed as 1

31
New cards

.intersection()

finds the values that are shared within both sets; join two sets but only includes common elements

32
New cards

.issubset()

the set is contained inside of another (mostly used in a if statement)

33
New cards

.issuperset()

contains another set in another (mostly use in a if statement)

34
New cards

Dictionaries

Purpose: A collection of values that are logically connected

Unique: DEFINED & MULTIPLE keys; each data point has a key/value pairing

Concept: Object-Oriented Programming

35
New cards

Function

A collection of “code” that can be “CALLED” multiple times from various points in our code

36
New cards

Parameter

passed in or returned out from a function

37
New cards

Argument

known or pre-defined parameter

38
New cards

PANDAs

Purpose: multidimensional table (2d)

39
New cards

series

one column of data; multiple series — creates a table

40
New cards

data frame

2 dimensional data (df)

41
New cards

import pandas as pd

is not necessary completely, but required if you want to use the features of PANDAs then you must do this

42
New cards

.Series()

makes a list of data into a series

43
New cards

df.head()

the first 5 rows are shown

44
New cards

df.tail()

the last 5 rows are shown

45
New cards

df.info()

when we want basic info about our df (how many rows, how many columns, what is the type of data)

46
New cards

pd.read_csv()

loads data directly into a dataframe

47
New cards

df.to_string()

outputs the df to a string

48
New cards

df.shape

how many rows and columns do we have in our df

49
New cards

.unique()

returns a list of all the unique values of columns

50
New cards

len(variable)

tells you how many in that list —> gives you a number

51
New cards

.isna()

how many rows in the columns have null values; returns a list of booleans

TRUE YES 1

FALSE NO 0

52
New cards

variable.sum()

counts how many in the list that we want to see that might have null values

53
New cards

.max()

gives the maximum value of a column

54
New cards

.min()

gives the minimum value of a column

55
New cards

.mean()

gives you the average of the column

56
New cards

.query()

looks through that section and gives you the specific row (subset) back to you either in another variable

columns/series need to be in backquotes

df.query(“ Starting Median Salary` > 75000”)

57
New cards

df.describe()

looks at all the descriptive statistics of the df

58
New cards

df.drop

drops the row in its entirety but there is some caution either in updating it or removing it in its entirety which switches its space

df.drop(index = 256, inplace = True) —> keeps it in place and just updates it

df.drop(index = 256) —> removes it completely and restructures the df

59
New cards
pd.to_numeric

df['Starting Median Salary'] = pd.to_numeric(df['Starting Median Salary'], errors='coerce')

takes the entire section and forces (“coerces it”) into numeric values

60
New cards
df.loc[21, 'Starting Median Salary'] = None
df.loc[22, 'Starting Median Salary'] = ""
df.loc[22, 'Starting Median Salary'] = 42600

used for updating a location by providing its index and column name, to which the person would add the value to “update it”

61
New cards

df.to_csv('/drive/My Drive/testfile.csv')  

to transfer the df into a csv file (comma separate value)

62
New cards
df['short_description'].replace(to_replace=r'^B',value='T', regex=True, inplace=True)

looks for patterns in data and completely updates with the regular expression value called “regex”

63
New cards
64
New cards
65
New cards