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

pd df sample frac

df.sample(frac=0.5, replace=True, random_state=1)
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 :: instagram python bot 
Python :: how to install docx in python 
Python :: python int to bytes 
Python :: concatenation in python 3 
Python :: create new column with length of old column value python 
Python :: discord py message link 
Python :: pd.get_dummies 
Python :: numpy mean 
Python :: mechanize python 
Python :: numpy get diagonal matrix from matrix 
Python :: how to check all the elements in a list are even or not 
Python :: django annotate vs aggregate 
Python :: python convert input into lowercase 
Python :: Copying a list using deepcopy() in python 
Python :: add item to python dictionary 
Python :: python asyncio gather 
Python :: messagebox python pyqt 
Python :: python callable type hint 
Python :: how many columns can a pandas dataframe have 
Python :: How do I iterate over a subfolder in Python 
Python :: correlation for specific columns 
Python :: apyori 
Python :: python get github file content 
Python :: series.string.split expand 
Python :: python save button 
Python :: how to use the super 
Python :: regex for digits python 
Python :: for loop to convert a list to lowercase 
Python :: pandas do not display index 
Python :: install json on python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =