Giter VIP home page Giter VIP logo

Comments (4)

simchuck avatar simchuck commented on May 23, 2024

Any thoughts on how to implement this check?

The AST node will look the same for both (ast.Call), so this needs to include a separate semantic check to determine the type of the base object:

type(pd)     # <class 'module'>
type(df)     # <class 'pandas.core.frame.DataFrame'>

We can still use the AST to confirm that node.func.attr == 'merge'

from pandas-vet.

deppen8 avatar deppen8 commented on May 23, 2024

Without exploring this, my first thought is maybe to catch all pd. calls and then check for merge. Anything besides pd. at the start of .merge is fine. If someone calls their DataFrame 'pd', they have bigger problems.

from pandas-vet.

deppen8 avatar deppen8 commented on May 23, 2024

Please ignore my closing of the issue - I mis-clicked.

from pandas-vet.

simchuck avatar simchuck commented on May 23, 2024

So to be clear, the AST does not retain any of the pandas semantics, so it doesn't have any idea what type of object the .merge() method is applied to. Without implementing some other way to determine the object type, we can infer based on the name of the object.

We can actually add one additional check to this -- if the object name is pd and the method has at least two arguments (left, right, ... ). All of the other arguments have default values, so only df.merge() could have a single argument.

from pandas-vet.

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.