Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between read_table and read_csv in pandas?

I've tested it and also checked the documentation with no visible differences.Either way i wanted to ask just in case.

Do you think that read_csv should be used only for csv's even though it works for other types? while read_table works for anything? and if they're the same while they exist?

like image 935
gsa Avatar asked Jan 16 '17 16:01

gsa


1 Answers

You can get either to work for general delimited files, the difference are the default params, for instance sep is '\t' (tab) for read_table but ',' for read_csv. They're both implemented the same underneath

If you look at the source

they call the same function with different separators:

read_csv = _make_parser_function('read_csv', sep=',')
read_csv = Appender(_read_csv_doc)(read_csv)

read_table = _make_parser_function('read_table', sep='\t')
read_table = Appender(_read_table_doc)(read_table)

and _make_parser_function:

def _make_parser_function(name, sep=','):

is a general method which accepts the sep arg

like image 149
EdChum Avatar answered Oct 31 '22 04:10

EdChum