Skip to content

Reading single index DataFrame with pandas > 0.20 causes MultiIndex issue #786

@sdementen

Description

@sdementen

During a training session this morning, a call on the laptop of a colleague of the function

@xlwings.func
@xlwings.arg('df', pandas.DataFrame, expand='vertical')
@xlwings.ret(expand="table", index=True)
def my_func(df):
    df.info()
    print(df.columns)

called with a range pointing to the first row of

month_start month
1/01/2018 Jan-18
1/02/2018 Feb-18
1/03/2018 Mar-18
1/04/2018 Apr-18
1/05/2018 May-18
1/06/2018 Jun-18
1/07/2018 Jul-18
1/08/2018 Aug-18
1/09/2018 Sep-18
1/10/2018 Oct-18
1/11/2018 Nov-18
1/12/2018 Dec-18
1/01/2019 Jan-19

prints the following

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 13 entries, 2018-01-01 to 2019-01-01
Data columns (total 1 columns):
(month,) 13 non-null object
dtypes: object(1)
memory usage: 208.0+ bytes
MultiIndex(levels=[['month', 'month_start']],
           labels=[[0]])

The MultiIndex part is weird as on my laptop I get

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 13 entries, 2018-01-01 to 2019-01-01
Data columns (total 1 columns):
month    13 non-null object
dtypes: object(1)
memory usage: 208.0+ bytes
Index(['month'], dtype='object')

We were both using xlwings=0.11.4 on a windows 7.0 laptop with Excel 2010.
Any hint of what could give this different behaviours ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions