Import NumPy under the alias np
.
Import pandas under the alias pd
.
Given the following NumPy array data
, create a pandas DataFrame named first_data_frame
that contains the same elements. Print the DataFrame to make sure the operation executed successfully.
data = np.round(np.random.randn(5,5),1)
#Solution goes here
Assign the values of row_labels
to the index of first_data_frame
. Print the DataFrame to make sure the operation executed successfully.
Hint: It will be easier to overwrite first_data_frame
by using another pd.DataFrame
method.
row_labels = ['one','two','three','four','five']
#Solution goes here
Assign the values of column_labels
to the columns of first_data_frame
. Note that there are two main ways to do this - you are free to chose the method of your choice. Print the DataFrame to make sure the operation executed successfully.
column_labels = ['alpha','beta','charlie','delta','echo']
#Solution goes here
Create a pandas Series named my_series
that contains the values from row alpha
of first_data_frame
. Print my_series
to make sure the operation executed successfully.
#Solution goes here
Create a new DataFrame called second_data_frame
that is equal to first_data_frame
but without row one
. Print second_data_frame
to make sure the operation executed successfully.
#Solution goes here
Create a new DataFrame called third_data_frame
that is equal to second_data_frame
, but without row charlie
. Print third_data_frame
to make sure the operation executed successfully.
#Solution goes here
Create a variable called row_two
that is equal to row two
from third_data_frame
. Print row_two
to make sure the operation executed successfully.
#Solution goes here
Print the shape of new_data.
new_data = np.round(np.random.randn(5,5),1)
#Solution goes here
Print a DataFrame that contains boolean values that indicate whether the elements of new_data
are greater than 1.
#Solution goes here
Print a NumPy array that contains only the elements of new_data
that are greater than 1.
#Solution goes here