1. Learn
  2. /
  3. Courses
  4. /
  5. Writing Efficient Code with pandas

Connected

Exercise

Random column selection

In the previous exercise, we examined two ways to select random rows from a pandas DataFrame. We can use the same functions to randomly select columns in a pandas DataFrame.

To randomly select 4 columns out of the poker dataset, you will use the following two functions:

  • The built-in pandas function .sample()
  • The NumPy random integer number generator np.random.randint()

Instructions 1/3

undefined XP
    1
    2
    3
  • Randomly select 4 columns from the poker_hands dataset using np.random.randint() .