Skip to content
Advertisement

Why file row count is more than len(dataframe)?

Good morning,

I’m new to python and data analysis world, so bear with me. I’ve been trying to understand why when counting file rows it gives the right answer but after converting to dataframe and counting len(datafarme), it gives a rowcount-1.

I’m sure it’s simple but I’ve googled it for about two hours and I didn’t find an answer yet, so would you kindly explain this to me:

JavaScript

EDIT: It seems that when converting txt to csv file, some lines went missing:

JavaScript

I’m wondering now, does it have something to do with using sep=’t’?

Advertisement

Answer

Reason is first row of csv is converted to columns, for avoid it and set columns names by range use header=None parameter:

JavaScript

Your code:

JavaScript

EDIT: In next files is used ", so pandas incorrect parsing. For avoid read starting by " and then next rows ending by " like one row use quoting=3 parameter for quoting=None:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement