Answers for "sample data pandas read_csv"

1

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)
Posted by: Guest on August-21-2020
0

csv file in dataframe

import pandas as pddf = pd.read_csv ('file_name.csv')print(df)
Posted by: Guest on September-07-2020

Python Answers by Framework

Browse Popular Code Answers by Language