Import and saving

Importing and saving data sets is desired to easily import and share the files. In order to accomplish this, we created two functions: function anonym.import_data() and function anonym.to_csv() Below we illustrate how to save and load models.

Import from csv

Importing a csv file can be done using the function :func:`anonym.import_data:

Reads the dataset from the given filepath.

param filepath:

Path to the dataset file.

type filepath:

str

param delim:

Delimiter used in the dataset file, by default ‘;’

type delim:

str, optional

Examples

>>> # Example 1
>>> filepath=r'./names_per_department.csv'
>>> filepath_fake=r'./names_per_department_fake.csv'
>>> # Load library
>>> from anonym import anonym
>>> # Initialize
>>> model = anonym()
>>> # Import csv data from file
>>> df = model.import_data(filepath, delim=';')
>>> print(df)
returns:

Dataset read from the file.

rtype:

pd.DataFrame

Saving to csv

Saving a data set can be done using the function anonym.to_csv():

Writes the DataFrame to a CSV file.

param df_fake:

DataFrame to be written to a file.

type df_fake:

pd.DataFrame

param filepath:

Path to the file where DataFrame will be written.

type filepath:

str

param delim:

Delimiter to be used in the file, by default ‘;’

type delim:

str, optional