Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Getting Random rows in dataframe

df = pandas.DataFrame(pandas.np.random.random(100))

# Randomly sample 70% of your dataframe
df_percent = df.sample(frac=0.7)

# Randomly sample 7 elements from your dataframe
df_elements = df.sample(n=7)
Comment

PREVIOUS NEXT
Code Example
Python :: unix to datetime python 
Python :: python remove non letters from string 
Python :: hibernate windows with python 
Python :: add picture to jupyter notebook 
Python :: selenium full screen python 
Python :: python hide console 
Python :: rgb to grayscale python opencv 
Python :: pygame.rect parameters 
Python :: import mean squared log error 
Python :: save plot python 
Python :: set axis limits matplotlib 
Python :: divide by zero error python exception handling 
Python :: plot keras model 
Python :: unzip in python 
Python :: python line chart 
Python :: ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected. 
Python :: pd.options.display.max_columns()pd.options.display.max_row() 
Python :: dataframe all companies except 
Python :: standardscaler into df data frame pandas 
Python :: iterate over df 
Python :: matplotlib clear plot 
Python :: python how to flatten a list 
Python :: python requests set user agent 
Python :: rmse in python 
Python :: pandas row starts with 
Python :: import xgboost 
Python :: numpy fill na with 0 
Python :: save dictionary python 
Python :: python format 2 digits 
Python :: python check if a file is empty 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =