DataFrameRField
Specific RField for Dataframe, these are loaded and dumped into a file.
DataFrames are dumped to Parquet (columnar, compressed, no code-execution risk on
read). For backward compatibility, load_from_file still reads legacy pickle files:
it sniffs the parquet magic bytes and falls back to read_pickle when they are
absent, so DataFrames saved before this change keep loading.
A DataFrame that Parquet cannot represent (e.g. object columns holding arbitrary Python objects) falls back to pickle on dump, so a save never fails.
WARNING: pickle files (legacy files, and the rare fallback above) are read with pandas' pickle reader, which can execute arbitrary code. Only load files that you trust. DataFrames written as Parquet are not affected by this risk.
:param FileRField: [description] :type FileRField: [type]
include_in_dict_view: boolstorage: RFieldStorageInitialize a FileRField with automatic file-based persistence.
The field is configured to store file path references in KV_STORE and is excluded from dict views since the actual data is in files.
Deserialize field value by loading data from the file path.
This method is marked as final and cannot be overridden. It delegates to
the load_from_file method which must be implemented by subclasses.
strTSerialize and save the field value to a file.
This abstract method must be implemented by subclasses to define how data is serialized and written to the file. It is called automatically when the Resource is saved.
The data MUST be written to the exact file path provided. The directory containing the file is guaranteed to exist.
DataFramestrGet the default value for this field.
If the default value is a Type or Callable, it will be called to generate a new default value. Otherwise, the default value is returned directly.
This ensures that mutable defaults (like lists or dicts) are not shared between Resource instances.
AnyLoad and deserialize the field value from a file.
This abstract method must be implemented by subclasses to define how data is read and deserialized from the file. It is called automatically when the Resource is loaded.
The file at file_path is guaranteed to exist when this method is called.
strDataFrameSerialize method not used for FileRField.
The actual serialization is handled by dump_to_file which is called
by the resource persistence layer. This method exists for interface
compatibility but should be ignored.
Anystr