0

Hi everybody I am beginner at machine learning in Python environment and I want to import only the first 30-40 rows of dataframe which has 30.000 rows for development.Thank you

s900n
  • 3,115
  • 5
  • 27
  • 35
  • What have you tried? Import from where? which libraries are you using? – FLab Mar 28 '17 at 11:31
  • I am using panda I tried pd.Excelfile command – s900n Mar 28 '17 at 11:32
  • 3
    Possible duplicate of [Way to read first few lines for pandas dataframe](http://stackoverflow.com/questions/15008970/way-to-read-first-few-lines-for-pandas-dataframe) – FLab Mar 28 '17 at 11:36
  • I want to import only the first 30 rows from excel to python=) – s900n Mar 28 '17 at 11:38

1 Answers1

1

You can use the pandas.read_csv 'nrows' parameter, like this:

pd.read_csv(myFilePath, nrows=30)

nrows : int, default None
Number of rows of file to read. Useful for reading pieces of large files

Full documentation can be found here

If you want to do it after you read all the file:

DataFrame.head(n=30)