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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:23:15+00:00 2026-06-17T01:23:15+00:00

Say I have the following file test.txt : Aaa Bbb Foo 0 Bar 1

  • 0

Say I have the following file test.txt:

Aaa Bbb
Foo 0
Bar 1
Baz NULL

(The separator is actually a tab character, which I can’t seem to input here.)
And I try to read it using pandas (0.10.0):

In [523]: pd.read_table("test.txt")
Out[523]:
   Aaa  Bbb
0  Foo  NaN
1  Bar    1
2  Baz  NaN

Note that the zero value in the first column has suddenly turned into NaN! I was expecting a DataFrame like this:

   Aaa   Bbb
0  Foo     0
1  Bar     1
2  Baz   NaN

What do I need to change to obtain the latter? I suppose I could use pd.read_table("test.txt", na_filter=False) and subsequently replace ‘NULL’ values with NaN and change the column dtype. Is there a more straightforward solution?

  • 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-17T01:23:16+00:00Added an answer on June 17, 2026 at 1:23 am

    I think this is issue #2599, “read_csv treats zeroes as nan if column contains any nan”, which is now closed. I can’t reproduce in my development version:

    In [27]: with open("test.txt") as fp:
       ....:     for line in fp:
       ....:         print repr(line)
       ....:         
    'Aaa\tBbb\n'
    'Foo\t0\n'
    'Bar\t1\n'
    'Baz\tNULL\n'
    
    In [28]: pd.read_table("test.txt")
    Out[28]: 
       Aaa  Bbb
    0  Foo    0
    1  Bar    1
    2  Baz  NaN
    
    In [29]: pd.__version__
    Out[29]: '0.10.1.dev-f7f7e13'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a text file named test.txt with the following contents: Apples.Purchased:
Say I have a file like the following: /** * A Test class *
I have the following thing in my bat file. say set path=c:\temp\test so basically
Say I have a directory with the following files in it: Test.bat Test_a.txt Test_b.txt
Say I have a file 'test.js' with the following contents: var test = 'something';
In a web project using jsp, I have following requirement Upload a file (say
Say I have the following chef role: name test description role for test run_list
Say I have the following DOM element in my piece of code: <div id=test>
Let's say I have following typed in my source file. var myFunction = function()
say if I have the following: using (ZipFile zip = new ZipFile()) { zip.AddFile(C:\\ReadMe.txt);

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.