You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I see pandas.read_csv() and pandas.read_excel() handle differently the skiprows argument. I have the same data in a CSV file and in an Excel file:
abc def
1 10
2 11
3 12
4 13
5 14
I want to use different column names when I read the data, so I specify the desired column names in names argument and I skip the first (header) row of my CSV & Excel files: pd.read_excel('test.xlsx', skiprows=0, names=['foo', 'bar']) returns with my expected result:
foo bar
0 1 10
1 2 11
2 3 12
3 4 13
4 5 14
I get the same expected result with pd.read_csv('test.csv', skiprows=1, names=['foo', 'bar']). But pd.read_csv('test.csv', skiprows=0, names=['foo', 'bar']) keeps the first (header) row of the input file:
As I see
pandas.read_csv()
andpandas.read_excel()
handle differently theskiprows
argument. I have the same data in a CSV file and in an Excel file:I want to use different column names when I read the data, so I specify the desired column names in
names
argument and I skip the first (header) row of my CSV & Excel files:pd.read_excel('test.xlsx', skiprows=0, names=['foo', 'bar'])
returns with my expected result:I get the same expected result with
pd.read_csv('test.csv', skiprows=1, names=['foo', 'bar'])
. Butpd.read_csv('test.csv', skiprows=0, names=['foo', 'bar'])
keeps the first (header) row of the input file:Is this the expected behavior of
skiprows
or something is wrong atpandas.read_csv()
?The text was updated successfully, but these errors were encountered: