Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas read_csv random rows

import pandas as pd
import numpy as np

filename = 'hugedatafile.csv'
nlinesfile = 10000000
nlinesrandomsample = 10000
lines2skip = np.random.choice(np.arange(1,nlinesfile+1), (nlinesfile-nlinesrandomsample), replace=False)
df = pd.read_csv(filename, skiprows=lines2skip)
Comment

PREVIOUS NEXT
Code Example
Python :: Add help text in Django model forms 
Python :: get video length python 
Python :: save dataframe to csv without index 
Python :: pandas dataframe histogram 
Python :: python get list of files in path 
Python :: python filter in ailst 
Python :: python random from normal distribution 
Python :: how to rotate the x label for subplot 
Python :: check odd numbers numpy 
Python :: qspinbox value changed 
Python :: python os get output 
Python :: python string list to float 
Python :: Import "decouple" could not be resolved Pylance 
Python :: from sklearn.preprocessing import standardscaler error 
Python :: python program to print list vertically without using loop 
Python :: extract text from a pdf python 
Python :: how to check if an element is visible on the web page in selenium python 
Python :: get rid of axes numbers matplotlib 
Python :: how to add the column to the beginning of dataframe 
Python :: how to separate x and y from mouse position python 
Python :: set axis ticks matplotlib 
Python :: how to check if a network port is open 
Python :: pandas sort columns by name 
Python :: python webbrowser 
Python :: python has duplicates 
Python :: python requests header 
Python :: how to provide default value when assign i ngvariables python 
Python :: remove special characters from dictionary python 
Python :: simple flask app 
Python :: python init matrix 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =