.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/04_omf_profile_blockmodel.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_04_omf_profile_blockmodel.py: OMF Profile Block Model ======================= Profiling a dataset is a common task in data analysis. This example demonstrates how to profile an OMF block model. The profile report is persisted inside the omf file. .. GENERATED FROM PYTHON SOURCE LINES 9-17 .. code-block:: Python import shutil import tempfile from pathlib import Path import pandas as pd from omfpandas import OMFPandasReader, OMFPandasWriter .. GENERATED FROM PYTHON SOURCE LINES 18-21 Instantiate ----------- Create the object OMFPandas with the path to the OMF file. .. GENERATED FROM PYTHON SOURCE LINES 21-32 .. code-block:: Python test_omf_path: Path = Path('../assets/test_file.omf') # create a temporary copy to preserve the original file temp_omf_path: Path = Path(tempfile.gettempdir()) / 'test_file_copy.omf' shutil.copy(test_omf_path, temp_omf_path) # Display the head of the original block model blocks: pd.DataFrame = OMFPandasReader(filepath=temp_omf_path).read_blockmodel(blockmodel_name='regular') blocks.head() .. raw:: html
random attr
x y z
10.5 10.5 -9.5 0.727986
-8.5 0.277389
-7.5 0.351741
-6.5 0.999272
-5.5 0.495092


.. GENERATED FROM PYTHON SOURCE LINES 33-37 Profile ------- Create the writer, write the pandera schema and the profile report into the file. The use of a pandera schema is optional, but it provides a way to describe the attributes in the dataset. .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: Python omfpw: OMFPandasWriter = OMFPandasWriter(filepath=temp_omf_path) omfpw.write_block_model_schema(blockmodel_name='regular', pd_schema_filepath=test_omf_path.with_suffix('.schema.yaml')) omfpw.profile_blockmodel(blockmodel_name='regular') .. rst-class:: sphx-glr-script-out .. code-block:: none Summarize dataset: 0%| | 0/5 [00:000.5') .. rst-class:: sphx-glr-script-out .. code-block:: none Summarize dataset: 0%| | 0/5 [00:000.5') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.516 seconds) .. _sphx_glr_download_auto_examples_04_omf_profile_blockmodel.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 04_omf_profile_blockmodel.ipynb <04_omf_profile_blockmodel.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 04_omf_profile_blockmodel.py <04_omf_profile_blockmodel.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_