Help on mission 10/14 Cluster Sampling

Can someone help in explaining this line of code - pd.Series(wnba[‘Team’].unique()).sample(4, random_state = 0)

Break all of it down into individual pieces and then see what each piece outputs -

  • What is wnba["Team"]?
  • What does unique() do?
  • What is wnba["Team"].unique()?
  • What does pd.Series() do?
  • What is pd.Series(wnba["Team"].unique())
  • What does sample() do?
  • What does sample(4, random_state=0) do?
  • What is pd.Series(wnba["Team"].unique()).sample(4, random_state=0)?

If at any point you get stuck on what something does or what the output should be then you can either -

  • Refer to the documentation, or
  • Print it out separately to see what the output might be at each step.

If you are still stuck or confused after the above, feel free to ask a question related to where you got stuck.