Skip to content

0.12: join with on= fails with TimeStamp and Int64 MultiIndex #5647

Closed
@bluefir

Description

@bluefir

I encountered a very strange problem in 0.12 when a straightforward join fails while it works just fine in 0.11.

df1

<class 'pandas.core.frame.DataFrame'>
Int64Index: 71958 entries, 0 to 104014
Data columns (total 3 columns):
FactorDate 71958 non-null values
FundSecNo 71958 non-null values
SourceFundSecNo 71958 non-null values
dtypes: datetime64ns, int64(2)

df1.dtypes

FactorDate datetime64[ns]
FundSecNo int64
SourceFundSecNo int64
dtype: object

df2

<class 'pandas.core.frame.DataFrame'>
MultiIndex: 94868 entries, (2011-10-18 00:00:00, 283) to (2011-10-19 00:00:00, 127419)
Data columns (total 2 columns):
DemeanGroupId 94868 non-null values
NormalizationGroupId 94868 non-null values
dtypes: float64(1), int64(1)

for ind in df2.index.levels:
    print(type(ind))

<class 'pandas.tseries.index.DatetimeIndex'>
<class 'pandas.core.index.Int64Index'>

test = df1.join(df2, on=['FactorDate', 'SourceFundSecNo'])
test

<class 'pandas.core.frame.DataFrame'>
Int64Index: 71958 entries, 0 to 104014
Data columns (total 5 columns):
FactorDate 71958 non-null values
FundSecNo 71958 non-null values
SourceFundSecNo 71958 non-null values
DemeanGroupId 0 non-null values
NormalizationGroupId 0 non-null values
dtypes: datetime64ns, float64(2), int64(2)

date = datetime.datetime(2011, 10, 18)
sfsn = 283
test.loc[(test.FactorDate == date) & (test.SourceFundSecNo == sfsn)]
          FactorDate  FundSecNo  SourceFundSecNo  DemeanGroupId  NormalizationGroupId

1 2011-10-18 00:00:00 283 283 NaN NaN
17933 2011-10-18 00:00:00 65213 283 NaN NaN

df2.loc[(date, sfsn)]

DemeanGroupId 350171
NormalizationGroupId 35
Name: (2011-10-18 00:00:00, 283), dtype: float64

I can attach the frames, but I forgot how to do it :-)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions