{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

Programming Part 2 Flashcards

(25 cards)

1
Q

What is a DataFrame in pandas?

A

A two-dimensional labeled data structure similar to a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Series in pandas?

A

A one-dimensional labeled array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you read a CSV into a pandas DataFrame?

A

Using pd.read_csv(‘filename.csv’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you inspect the first few rows of a DataFrame?

A

Using the .head() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you get column names from a DataFrame?

A

Using df.columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you select a column from a DataFrame?

A

Using df[‘column_name’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you select multiple columns?

A

Using df[[‘col1’, ‘col2’]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is .loc[] used for in pandas?

A

Label-based indexing for rows and columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is .iloc[] used for in pandas?

A

Position-based indexing for rows and columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you filter rows based on a condition?

A

Using boolean indexing: df[df[‘column’] > value]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you check for missing values?

A

Using df.isnull()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you drop rows with missing values?

A

Using df.dropna()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you fill missing values?

A

Using df.fillna(value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you rename columns in pandas?

A

Using df.rename(columns={‘old’: ‘new’})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you change the data type of a column?

A

Using df[‘col’] = df[‘col’].astype(new_type)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does .groupby() do?

A

Groups rows based on column values for aggregation.

17
Q

How do you calculate mean for each group?

A

df.groupby(‘col’).mean()

18
Q

What is the purpose of .agg()?

A

To apply multiple aggregation functions at once.

19
Q

How do you count unique values in a column?

A

Using df[‘col’].nunique()

20
Q

What does df.value_counts() do?

A

Counts occurrences of unique values in a Series.

21
Q

How do you concatenate two DataFrames?

A

Using pd.concat([df1, df2])

22
Q

How do you merge two DataFrames?

A

Using pd.merge(df1, df2, on=’key’)

23
Q

What is the difference between merge and join in pandas?

A

merge is a method; join is an attribute method for DataFrames.

24
Q

How do you reset the index of a DataFrame?

A

Using df.reset_index()

25
How do you set a column as the index?
Using df.set_index('column')