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 8842523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:58:48+00:00 2026-06-14T10:58:48+00:00

I would like to import the following csv as strings not as int64. Pandas

  • 0

I would like to import the following csv as strings not as int64. Pandas read_csv automatically converts it to int64, but I need this column as string.

ID
00013007854817840016671868
00013007854817840016749251
00013007854817840016754630
00013007854817840016781876
00013007854817840017028824
00013007854817840017963235
00013007854817840018860166
df = read_csv('sample.csv')

df.ID
>>

0   -9223372036854775808
1   -9223372036854775808
2   -9223372036854775808
3   -9223372036854775808
4   -9223372036854775808
5   -9223372036854775808
6   -9223372036854775808
Name: ID

Unfortunately using converters gives the same result.

df = read_csv('sample.csv', converters={'ID': str})
df.ID
>>

0   -9223372036854775808
1   -9223372036854775808
2   -9223372036854775808
3   -9223372036854775808
4   -9223372036854775808
5   -9223372036854775808
6   -9223372036854775808
Name: ID
  • 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-14T10:58:49+00:00Added an answer on June 14, 2026 at 10:58 am

    Just want to reiterate this will work in pandas >= 0.9.1:

    In [2]: read_csv('sample.csv', dtype={'ID': object})
    Out[2]: 
                               ID
    0  00013007854817840016671868
    1  00013007854817840016749251
    2  00013007854817840016754630
    3  00013007854817840016781876
    4  00013007854817840017028824
    5  00013007854817840017963235
    6  00013007854817840018860166
    

    I’m creating an issue about detecting integer overflows also.

    EDIT: See resolution here: https://github.com/pydata/pandas/issues/2247

    Update as it helps others:

    To have all columns as str, one can do this (from the comment):

    pd.read_csv('sample.csv', dtype = str)
    

    To have most or selective columns as str, one can do this:

    # lst of column names which needs to be string
    lst_str_cols = ['prefix', 'serial']
    # use dictionary comprehension to make dict of dtypes
    dict_dtypes = {x : 'str'  for x in lst_str_cols}
    # use dict on dtypes
    pd.read_csv('sample.csv', dtype=dict_dtypes)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following: >>>import struct >>>struct.unpack('!d', ('40d11998e5035288').decode('hex'))[0] >>> >>>17510.3889778429 I would like to be able
How can I import a CSV file into a MySQL table? I would like
I would like to do the following: import StringIO, uu my_data = StringIO.StringIO() #
i would like to import csv file in mysql database. my query would be
I am modifying a website on wordpress (codex) and I would like to import
I would like to be able to import TFS tasks / work items into
I would like to know what is the best import strategy within django reusable
I have a csv file that looks something like this (actual file has many
I have a application.css.scss with the following content - @import bootstrap Now I would
Hey all. So I have a collection of csv files which I would like

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.