Closed
Description
related #6322
Hi,
I've found this accidentally that after the subtraction between df1
and df2
, the nan
in the multi index has turned to a string
rather than the original float
type. And it's also weird that this issue only happens with the parse_dates
set to False
.
The following is the code to reproduce:
import StringIO
from pandas import DataFrame
index = ['ID', 'Index']
input1 = '''"value","ID","Index"
"0.0","B9",""
"0.0","B",""
'''
input2 = '''"value","ID","Index"
"1.5375969","M","Blah"
'''
df1 = DataFrame.from_csv(StringIO.StringIO(input1), index_col=index, parse_dates=False)
df2 = DataFrame.from_csv(StringIO.StringIO(input2), index_col=index, parse_dates=False)
## The following two lines can work as expected
#df1 = DataFrame.from_csv(file1, index_col=index, )
#df2 = DataFrame.from_csv(file2, index_col=index, )
diff = df2['value'] - df1['value']
print diff.index[0], diff.index[1] # => ('B', 'nan') ('B9', 'nan')
print df1.index[0], df1.index[1] # => ('B9', nan) ('B', nan)
versions of pandas and it's dependencies:
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.5.final.0
python-bits: 64
OS: Darwin
OS-release: 13.1.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: zh_HK.UTF-8
pandas: 0.13.1
Cython: None
numpy: 1.8.1
scipy: None
statsmodels: None
IPython: 1.1.0
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.2
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
sqlalchemy: None
lxml: None
bs4: None
html5lib: None
bq: None
apiclient: None