fcapy.context.converters¶
This module provides a number of functions to read/write FormalContext object from/to a file
Functions
|
Create FormalContext object based on pandas.DataFrame |
|
Read FormalContext from .csv file |
|
Read FormalContext from .cxt file or from |
|
Read FormalContext from .json file or from |
|
Convert FormalContext object to pandas.DataFrame object |
|
Write FormalContext object to the .csv file |
|
Write FormalContext object to the .cxt file |
|
Write FormalContext object to the .json file |
- fcapy.context.converters.from_pandas(dataframe)¶
Create FormalContext object based on pandas.DataFrame
context.object_namesare parsed fromdataframe.index.context.column_namesare parsed fromdataframe.columns- Parameters
dataframe (pandas.DataFrame) –
- Returns
ctx
- Return type
FormalContext
- fcapy.context.converters.read_csv(path, sep=',', word_true='True', word_false='False')¶
Read FormalContext from .csv file
- Parameters
path (str) – A path to requested .csv file
sep (str) – A separator in the .csv file
word_true (str) – A string placeholder corresponding to True values in the .csv file
word_false (str) – A string placeholder corresponding to False values in the .csv file
- Returns
ctx – The loaded FormalContext object
- Return type
FormalContext
- fcapy.context.converters.read_cxt(path=None, data=None)¶
Read FormalContext from .cxt file or from
dataattribute- Parameters
path (str) – A path to requested .cxt file
data (str) – CXT formatted data (if it is already loaded into python)
- Returns
ctx – The loaded FormalContext object
- Return type
FormalContext
- fcapy.context.converters.read_json(path=None, data=None)¶
Read FormalContext from .json file or from
dataattribute- Parameters
path (str) – A path to requested .json file
data (str) – JSON formatted data (if it is already loaded into python)
- Returns
ctx – The loaded FormalContext object
- Return type
FormalContext
- fcapy.context.converters.to_pandas(context)¶
Convert FormalContext object to pandas.DataFrame object
context.object_namesare turned intodf.index.context.column_namesare turned intodf.columns- Parameters
context (FormalContext) – A context to convert
- Returns
df – The binary dataframe based on FormalContext object
- Return type
pandas.DataFrame
- fcapy.context.converters.write_csv(context, path=None, sep=',', word_true='True', word_false='False')¶
Write FormalContext object to the .csv file
- Parameters
context (FormalContext) – A context to write to a file
path (str) – A path to the file to write a FormalContext object
sep (str) – A separator in the .csv file
word_true (str) – A string placeholder corresponding to True values in the .csv file
word_false (str) – A string placeholder corresponding to False values in the .csv file
- Returns
file_data – The date from the .csv file. Returned if
pathis None- Return type
str
- fcapy.context.converters.write_cxt(context, path=None)¶
Write FormalContext object to the .cxt file
- Parameters
context (FormalContext) – A context to write to a file
path (str) – A path to the file to write a FormalContext object
- Returns
file_data – The date from the .cxt file. Returned if
pathis None- Return type
str
- fcapy.context.converters.write_json(context, path=None)¶
Write FormalContext object to the .json file
- Parameters
context (FormalContext) – A context to write to a file
path (str) – A path to the file to write a FormalContext object
- Returns
file_data – The date from the .json file. Returned if
pathis None- Return type
str