Import NumPy under the alias np
.
Import pandas under the alias pd
.
Given the pandas Series my_series
, generate a NumPy array that contains only the unique values from my_series
. Assign this new array to a variable called my_array
. Print my_array
to ensure that the operation has been executed successfully.
my_series = pd.Series([1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9])
my_series
#Solution goes here
Given the pandas DataFrame my_data_frame
, generate a NumPy array that contains only the unique values from the second column. Assign this new array to a variable called another_array
. Print another_array
to ensure the operation has been executed successfully.
my_data_frame = pd.DataFrame(np.random.randn(3,5))
my_data_frame
#Solution goes here
Count the occurence of every element within the my_series
variable that was created earlier in these practice problems.
Given the function triple_digit
, apply this to every element within my_series
.
def triple_digit(x):
return x + x*10 + x*100
#Solution goes here
Sort the my_data_frame
variable that we created earlier based on the contents of its second column.