Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:25:09+00:00 2026-06-13T03:25:09+00:00

I am going through the ‘Python for Data Analysis’ book and having trouble in

  • 0

I am going through the ‘Python for Data Analysis’ book and having trouble in the ‘Example: 2012 Federal Election Commision Database’ section reading the data to a DataFrame. The trouble is that one of the columns of data is always being set as the index column, even when the index_col argument is set to None.

Here is the link to the data : http://www.fec.gov/disclosurep/PDownload.do.

Here is the loading code (to save time in the checking, I set the nrows=10):

import pandas as pd
fec = pd.read_csv('P00000001-ALL.csv',nrows=10,index_col=None)

To keep it short I am excluding the data column outputs, but here is my output (please not the Index values):

In [20]: fec

Out[20]:
<class 'pandas.core.frame.DataFrame'>
Index: 10 entries, C00410118 to C00410118
Data columns:
...
dtypes: float64(4), int64(3), object(11)

And here is the book’s output (again with data columns excluded):

In [13]: fec = read_csv('P00000001-ALL.csv')
In [14]: fec
Out[14]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 1001731 entries, 0 to 1001730
...
dtypes: float64(1), int64(1), object(14)

The Index values in my output are actually the first column of data in the file, which is then moving all the rest of the data to the left by one. Would anyone know how to prevent this column of data to be listed as an index? I would like to have the index just +1 increasing integers.

I am fairly new to python and pandas, so I apologize for any inconvenience. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:25:10+00:00Added an answer on June 13, 2026 at 3:25 am

    Quick Answer

    Use index_col=False instead of index_col=None when you have delimiters at the end of each line to turn off index column inference and discard the last column.

    More Detail

    After looking at the data, there is a comma at the end of each line. And this quote (the documentation has been edited since the time this post was created):

    index_col: column number, column name, or list of column numbers/names, to use as the index (row labels) of the resulting DataFrame. By default, it will number the rows without using any column, unless there is one more data column than there are headers, in which case the first column is taken as the index.

    from the documentation shows that pandas believes you have n headers and n+1 data columns and is treating the first column as the index.


    EDIT 10/20/2014 – More information

    I found another valuable entry that is specifically about trailing limiters and how to simply ignore them:

    If a file has one more column of data than the number of column names, the first column will be used as the DataFrame’s row names: …

    Ordinarily, you can achieve this behavior using the index_col option.

    There are some exception cases when a file has been prepared with delimiters at the end of each data line, confusing the parser. To explicitly disable the index column inference and discard the last column, pass index_col=False: …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Going through some documentation on modifying CGImageRef data, I came across a strange example
Going through the php.net site, it had an example for header, which says would
While going through one project, I have seen that the memory data is 8
Going through classic data structures and have stopped on linked lists.Just implemented a circular
Going through the Tutorial v2.0, I've just added data access to the sdf database.
While going through one of the problems in Python Challenge , I am trying
While going through the Intermediate Perl book I noticed a section on Schwartzian Transforms
Im going through the beginning Django ecommerce book, and I am stuck on trying
Going through Learn Python the Hard Way, lesson 25. I try to execute the
After going through the Appendix A, C# Coding Style Conventions of the great book

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.