GithubHelp home page GithubHelp logo

Comments (6)

rxin avatar rxin commented on June 17, 2024

Does Python automatically materialize all the properties when the class is created? If yes, I definitely agree we shouldn't create "values" eagerly ...

from koalas.

garawalid avatar garawalid commented on June 17, 2024

Yes, it does.
Here is an example. I implemented values as property in _Frame class.

    @property
    def values(self):
        return self.toPandas().values

Running this code will show us that the property values contains already the data as numpy array.

df = pd.DataFrame({'a': [4, 2, 3, 4, 8, 6],
                   'b': [1, 2, 9, 4, 2, 4],
                   'c': ["one", "three", "six", "seven", "one", "5"]},
                   index=[10, 20, 30, 40, 50, 60])

ddf = self.spark.from_pandas(df)

A screen capture from the debugger stopped after creating ddf

values

from koalas.

AbdealiLoKo avatar AbdealiLoKo commented on June 17, 2024

A debugging tool would typically get all attributes in dir() and request for every attribute. Checking it in a debugger may not be an accurate test

from koalas.

garawalid avatar garawalid commented on June 17, 2024

@AbdealiJK
Thanks! You are right, it's not an accurate test.
I tried it with this simple test, and the message doesn't appear when we create the dataframe.

@property
def values(self):
    print("executed !")
    return self.toPandas().values

from koalas.

garawalid avatar garawalid commented on June 17, 2024

So, we can say that properties are lazy by default!

from koalas.

rxin avatar rxin commented on June 17, 2024

Thanks. Looks like we are safe here. I'm going to close this ticket. Feel free to reopen if there is an issue in the future.

from koalas.

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.