I would like to declare my dataframe as constant, so no matter what operations are happening in a modeule it's values or column names do not change. I know that it is possible to define constant variables using slot =() like so,
class CONST(object): __slots__ = () my_constant = 123 CONST = CONST() CONST.my_constant = 345 # AttributeError: 'CONST' object attribute 'my_constant' is read-only however when i try the same thing on pandas dataframe, it is not constant anymore.
import pandas as pd df1 = pd.DataFrame({'text': ['the weather is good']}) class CONST(object): __slots__ = () my_constant = pd.DataFrame({'text': ['the weather is good']}) CONST = CONST() CONST.my_constant.columns =['message'] I receive no error this time saying that it is read_only. I also looked at this response here but got the same output that shows my pandas dataframe is not read-only.