Pandas Foundation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How do you get summary info of a DataFrame?

A

df.info()

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

How do you represent a DataFrame as a NumpyArray?

A

You can use the DataFrame attribute .values to represent a DataFrame df as a NumPy array. You can also pass pandas data structures to NumPy methods.

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

How do you build a DatetimeIndex out of the list of date strings?

A

pd.to_datetime()

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

What is REINDEXING the INDEX used for?

A

Reindexing is useful in preparation for adding or otherwise combining two time series data sets. To reindex the data, we provide a new index and ask pandas to try and match the old data to the new index. If data is unavailable for one of the new index dates or times, you must tell pandas how to fill it in. Otherwise, pandas will fill with NaN by default.

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

How do you Reindex without fill method?

A

ts3 = ts2.reindex(ts1.index)

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

Downsample the ‘Temperature’ column of df to 6 hour data using .resample(‘6h’) and .mean(). Assign the result to df1.

A

df1 = df.Temperature.resample(‘6H’).mean()

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

Print the dry_bulb_faren temperature between 8 AM and 9 AM on June 20, 2011? ( To remember syntax)

A

print(df_clean.loc[‘June 20 2011 08:00:00’:’June 20 2011 09:00:00’, ‘dry_bulb_faren’])

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

Convert the wind_speed and dew_point_faren columns to numeric values

A

df_clean[‘wind_speed’] = pd.to_numeric(df_clean[‘wind_speed’], errors=’coerce’)

df_clean[‘dew_point_faren’] = pd.to_numeric(df_clean[‘dew_point_faren’], errors=’coerce’)

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

Print the median of the dry_bulb_faren column for the time range ‘2011-Apr’:’2011-Jun’ ?

A

print(df_clean.loc[‘2011-Apr’:’2011-Jun’, ‘dry_bulb_faren’].median())

(this is the format for the DateTime Index)

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

daily_temp_2011 = df_clean[‘dry_bulb_faren’].values

What does this line of code do?

A

.values extracts all the values of the columns as a numpy array ( without the .values the values of the column are extracted as a Series)

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