Giter VIP home page Giter VIP logo

Comments (1)

Pekton avatar Pekton commented on July 26, 2024

Modin version checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest released version of Modin.
  • I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow this guide.)

Reproducible Example

import modin.pandas as pd

data1=pd.read_excel('abc.xlsx', header=[0,1]) # multiple headers

def anyFuncB(x):
    do something
    return x

def anyFuncA(x)
    x.loc[data1[('col0','col1')].apply(anyFuncB)] #here cause the error, apply() results in a pd.Series

data = pd.read_excel('def.xlsx')
data.groupby(by='col0').apply(anyFuncA)

Issue Description

By just applying dataframe0.apply(anyFunc0), everything was good.

After applying dataframe0.groupby().apply(anyFunc0), if another dataframe1 has multi index and it runs dataframe1[('col0', 'col1')].apply(anyFunc1), File "/usr/local/python3.10/lib/python3.10/site-packages/modin/pandas/series.py", line 713, in apply if result.name == self.index[0]: raises ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all(), because here result.name is a tuple with 2 items and self.index[0] is a numpy.int64, the result of comparison is a list contents two boolean values, my temp fix is adding following code:

elif return_type == "Series":
    try:
        if result.name == self.index[0]:
            result.name = None
    except:
        if (result.name == self.index[0]).all():
            result.name = None

other solution could be to determine if result.name and self.index[0] is single value or not.

Expected Behavior

make the comparison correct

Error Logs

Installed Versions

solution modified to:

if  isinstance(_ := (result.name == self.index[0]), np.ndarray):
                if _.all():
                    result.name = None
            elif _:
                result.name = None

from modin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.