ENGR 131 - Python Exam - not matplotlib

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

42 Terms

1
New cards

x**2

x²

2
New cards

//

division (truncate to nearest integer)

3
New cards

.upper()

make all characters uppercase

4
New cards

.lower()

make all characters lowercase

5
New cards

.title()

capitalize first letter of every word

6
New cards

.capitalize()

capitalize the first letter of whole string, rest lowercase

7
New cards

.split()

split string into words separated by “ “

8
New cards

random.seed()

initialize random generator

9
New cards

random.randint(a, b)

random integer between a and b

10
New cards

random.choice()

random thing from a sequence

11
New cards

break

exit loop immediately

12
New cards

continue

skip the rest of the loop, retest condition to do loop again

13
New cards

pass

does nothing - useless

14
New cards

return

exit function and output something

15
New cards

.insert(i, a)

insert a into list at index i

16
New cards

.append(a)

add a to end of list

17
New cards

np.shape()

Dimensions of np array

18
New cards

np.ndim()

Number of dimensions of np array

19
New cards

np.dtype()

Data type of elements in np array

20
New cards

pd.DataFrame(data)

create pd data frame w data

21
New cards

pd.read_csv("abc.csv")

import abc.csv into pandas

22
New cards

pd.read_excel("abc.xlsx")

import abc.xlsx into pandas

23
New cards

df.head(n)

First n rows of dataframe

24
New cards

df.columns()

List of dataframe column names

25
New cards

df.to_csv("output.csv", index=False)

Export df as output.csv

26
New cards

df.to_excel("output.xlsx", index=False)

Export df as output.xlsx

27
New cards

df.to_csv("output.txt", sep = "\t", index=False)

Export df as output.txt file, separate columns by tabbing over

28
New cards

with pd.ExcelWriter("output.xlsx", engine = "openpyxl") as writer:

df.to_excel(writer, sheet_name = "Sheet1", index = False)

Export df to Sheet1 in output.xlsx

29
New cards

df[["Name", "Age"]]

df columns “Name” and “Age”

30
New cards

pd.merge(df1, df2, on="c1")

combine df1 and df2, using the same row when the column “c1” is equal

31
New cards

df[df["r1"] condition]

filter df based on when row “r1” follows condition

32
New cards

df.sort_values(by="r1")

sort df by row “r1”

33
New cards

df.sort_values(by="r1", ascending=False)

sort df by row “r1” in descending order

34
New cards

df.isnull()

Missing values in df

35
New cards

df.isnull().sum()

Number of missing values per column in df

36
New cards

df.dropna()

Remove rows of df with missing values

37
New cards

df.fillna(0)

Replace missing values in df with 0

38
New cards

df.drop_duplicates()

Remove duplicate rows in df

39
New cards

df.rename(columns={"c1": "C1"})

rename column “c1” to “C1”

40
New cards

df["c1"].astype(float)

convert column “c1” to floats

41
New cards

df.groupby("Road")["Speed"].mean()

show average value of “Speed” (column) for each road in “Road”

42
New cards

df.describe()

Statistical analysis of df (mean, max, min, std)