Package metatables
Classes
class MetaTable (df: pandas.core.frame.DataFrame, meta: pyreadstat._readstat_parser.metadata_container)-
creates MetaTable object that makes data wrangling of files read with pyreadstat easy
Args
df:pd.DataFrame- DataFrame read with pyreadstat
meta:pyreadstat._readstat_parser.metadata_container- pyreadstat metadata
Methods
def return_components(self) ‑> tuple[pandas.core.frame.DataFrame, pyreadstat._readstat_parser.metadata_container]-
Returns the updated DataFrame and metadata that are contained within the object
Returns
tuple[pd.DataFrame, pyreadstat._readstat_parser.metadata_container]- returns tuple with objects
def select_columns(self, columns: list)-
selects the given columns and removes all others.
Args
columns:list- Columns to select
def show(self, variable: str)-
Shows info about the value labels and variable label of the given variable
Args
variable:str- Variable to be shown
def val_lab(self, columns: list[str], labels: Union[dict[int, str], str])-
Changes the value labels of the given columns
Args
columns:list[str]- A list of columns that need new value labels
labels:Union[dict[int, str], str]- A dictionary with new labels {1 : "label for code 1", 2: "label for code 2"} or the variable name with the labels to be used "variable_name"
def var_lab(self, columns: list[str], text: str)-
Changes the variable labels of the given columns
Args
columns:list[str]- A list of columns that need a new variable label
text:str- Text of the variable label
def write_sav(self, path: str)-
Writes a sav file of the MetaTable object which includes a Dataframe and the metadata.
Args
path:str- Path of the new file, includes the file name. To save the file in the package directory use "./filename.sav"