0

Pseudo code

class some_class:
    arg1 = 12345

    def __init__(self, arg1):
        self.variable1 = 1
        self.variable2 = 123
        self.variable_arg1 = arg1
...

So I would like a data frame with columns names variable and value, where
variable = variable1, variable2, variable_arg1
value = 1, 123, arg1

This is just an example so there are only three instances, but need a solution if there are a million.

Maybe as a bonus, I need the above in Pandas dataframe. How would I do this in tidypolars?

  • If you used a dictionary instead of named attributes, the conversion into a dataframe would be much simpler... – Serge Ballesta Jan 17 '23 at 16:34
  • It's not clear what you've already tried and where you're stuck, so I've closed the question under another one that covers the first step in the process: getting instance attributes. You'll still need to do a bit of work to get it into a dataframe, but it seems straightforward to me at least: separate the keys and values into their own columns, basically. You can [edit] to clarify if needed. Check out [How to ask a good question](/help/how-to-ask) for tips. – wjandrea Jan 17 '23 at 20:09

0 Answers0