Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas sample

>>> df['num_legs'].sample(n=3, random_state=1)
fish      0
spider    8
falcon    2
Name: num_legs, dtype: int64
Comment

pandas df sample

df['num_legs'].sample(n=3, random_state=1)
Comment

df.sample(frac=1)

df.sample(frac=1, replace=True, random_state=1)
      num_legs  num_wings  num_specimen_seen
dog          4          0                  2
fish         0          0                  8
Comment

pd df sample frac

df.sample(frac=0.5, replace=True, random_state=1)
Comment

pandas sample frac

df.sample(frac=0.5, replace=True, random_state=1)
      num_legs  num_wings  num_specimen_seen
dog          4          0                  2
fish         0          0                  8
Comment

pandas sample

>>> df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
...                    'num_wings': [2, 0, 0, 0],
...                    'num_specimen_seen': [10, 2, 1, 8]},
...                   index=['falcon', 'dog', 'spider', 'fish'])
>>> df
        num_legs  num_wings  num_specimen_seen
falcon         2          2                 10
dog            4          0                  2
spider         8          0                  1
fish           0          0                  8
Comment

pandas sample

# Extract 10% of your dataframe
df.sample(frac=0.1, replace=True, random_state=1)
Comment

PREVIOUS NEXT
Code Example
Python :: .close() python 
Python :: convert days hours minutes into seconds python 
Python :: vars() python 
Python :: python unsigned to signed integer 
Python :: finding anagrams in python 
Python :: pyplot save image 
Python :: df add column from dict 
Python :: empty python file 
Python :: unban member using ID discord.py 
Python :: python polymorphism 
Python :: mute command discord.py 
Python :: days calculator python 
Python :: login python code 
Python :: python label 
Python :: how to make one list from nested list 
Python :: bounding box in matplotlib 
Python :: Python communication with serial port 
Python :: how to convert user integer input to string in python 
Python :: store message sent by user in string discord py 
Python :: Python list tutorial for beginners 
Python :: np.vstack python 
Python :: how to send a command to cmd using python 
Python :: python how to find the highest even in a list 
Python :: average python 
Python :: how to run a python package from command line 
Python :: new line 
Python :: python socket get client ip address 
Python :: import turtle 
Python :: how to sum only the odd values in python 
Python :: python dataframe find no of true 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =