Pandas: Reading TSV into DataFrame

2019-09-16 07:20发布

I'm using Python 2.7 and have a TSV formatted as follows (368 rows × 3 columns):

date    dayOfWeek    pageviews
2016    4            3920
...

I have a Jupyter notebook saved in the same location as the TSV. I'm running this code:

import pandas as pd
pd.read_table('query_explorer.tsv')

I get back a dataframe that's 736 rows × 3 columns and filled with NaNs. It's interesting too, because I should have only 368 rows (exactly half of what I do have).

Any idea what's going on here?

1条回答
趁早两清
2楼-- · 2019-09-16 07:41

How about:

pd.read_table('query_explorer.tsv',delim_whitespace=True,header=0)
查看更多
登录 后发表回答