Pass pandas dataframe into class

You don't need a @staticmethod for this. You can pass the pandas DataFrame whenever you're creating instances of the class:

class MyClass:

    def __init__(self, my_dataframe):
        self.my_dataframe = my_dataframe

a = MyClass(my_dataframe)
b = MyClass(my_dataframe)

At this point, both a and b have access to the DataFrame that you've passed and you don't have to read the DataFrame each time. You can read the data from the CSV file once, create the DataFrame and construct as many instances of your class as you like (which all have access to the DataFrame).


I would think you could create the dataframe in the first instance with

a = MyClass(my_dataframe)

and then just make a copy

b = a.copy()

Then b is independent of a