Giter Club home page Giter Club logo

Comments (2)

mroeschke avatar mroeschke commented on July 24, 2024

Thanks for the report. But this is an upstream issue as pandas would need an arrow compute kernel to call on mod apache/arrow#28497

Going to close as an upstream issue

from pandas.

seanslma avatar seanslma commented on July 24, 2024

Thanks. Seems the upstream issue has been there for a few years now.

Here I provide a workaround that might be helpful to anyone who needs the mod function.

def pa_mod(val, divisor):
    if divisor <= 0:
        raise ValueError('Divisor must be a positive integer')
    if divisor & (divisor - 1) == 0:
       remainder = val & (divisor - 1)
    else:
       quotient = val // divisor
       remainder = val - (quotient * divisor)
    return remainder

Test code:

d = pd.DataFrame({'x': np.arange(-10, 10)}, dtype='int64[pyarrow]')
d = d.assign(y=pa_mod(d['x'], 3))
print(d)

d = pd.DataFrame({'x': np.arange(-10, 10)-0.5}, dtype='float64[pyarrow]')
d = d.assign(y=pa_mod(d['x'], 3))
print(d)

from pandas.

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.