How to use the vortexasdk.result_conversions.create_dataframe function in vortexasdk

To help you get started, we’ve selected a few vortexasdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github V0RT3X4 / python-sdk / vortexasdk / endpoints / vessel_movements_result.py View on Github external
]
        ```

        """
        if columns is None:
            columns = DEFAULT_COLUMNS

        logger.debug("Converting each VesselMovement to a flat dictionary")
        flatten = functools.partial(
            convert_vessel_movement_to_flat_dict, cols=columns
        )

        with Pool(os.cpu_count()) as pool:
            records = pool.map(flatten, super().to_list())

        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=records,
            logger_description="VesselMovements",
        )
github V0RT3X4 / python-sdk / vortexasdk / endpoints / timeseries_result.py View on Github external
def to_df(self, columns=None) -> pd.DataFrame:
        """Represents the timeseries as a dataframe.

        Returns a `pd.DataFrame`, of time series items with columns:
         key: The time series key
         value: The value of the time series for a given key
         count: The number of records contributing to this time series record.

        # Example:

        If we're aggregating Crude exports in tonnes by day, then the `key` column holds the date,
        the `value` column holds the Crude exports on that day, and the `count` column holds
        the number of cargo movements contributing towards this day's tonnage.

        """
        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=super().to_list(),
            logger_description="TimeSeries",
        )
github V0RT3X4 / python-sdk / vortexasdk / endpoints / corporations_result.py View on Github external
def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent corporations as a `pd.DataFrame`.

        # Arguments
            columns: The corporation features we want in the dataframe. Enter `columns='all'` to include all features.
            Defaults to `columns = ['id', 'name', 'corporate_entity_type']`.


        # Returns
        `pd.DataFrame` of corporations.

        """
        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=super().to_list(),
            logger_description="Corporations",
        )
github V0RT3X4 / python-sdk / vortexasdk / endpoints / vessels_result.py View on Github external
def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent vessels as a `pd.DataFrame`.

        # Arguments
            columns: The vessel features we want in the dataframe. Enter `columns='all'` to include all features.
            Defaults to `columns = ['id', 'name', 'imo', 'vessel_class']`.


        # Returns
        `pd.DataFrame` of vessels.

        """
        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=super().to_list(),
            logger_description="Vessels",
        )
github V0RT3X4 / python-sdk / vortexasdk / endpoints / cargo_movements_result.py View on Github external
]
        ```

        """
        if columns is None:
            columns = DEFAULT_COLUMNS

        flatten = functools.partial(
            convert_cargo_movement_to_flat_dict, cols=columns
        )

        logger.debug("Converting each CargoMovement to a flat dictionary")
        with Pool(os.cpu_count()) as pool:
            records = pool.map(flatten, super().to_list())

        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=records,
            logger_description="CargoMovements",
        )
github V0RT3X4 / python-sdk / vortexasdk / endpoints / attributes_result.py View on Github external
def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent attributes as a `pd.DataFrame`.

        # Arguments
            columns: The attributes features we want in the dataframe. Enter `columns='all'` to include all features.
            Defaults to `columns = ['id', 'name', 'type']`.


        # Returns
        `pd.DataFrame` of attributes.

        """
        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=super().to_list(),
            logger_description="Attributes",
        )
github V0RT3X4 / python-sdk / vortexasdk / endpoints / products_result.py View on Github external
def to_df(self, columns=None) -> pd.DataFrame:
        """
        Represent products as a `pd.DataFrame`.

        # Arguments
            columns: The product features we want in the dataframe. Enter `columns='all'` to include all features.
            Defaults to `columns = ['id', 'name', 'layer.0', 'parent.0.name']`.


        # Returns
        `pd.DataFrame` of products.

        """
        flattened_dicts = [flatten_dictionary(p) for p in super().to_list()]

        return create_dataframe(
            columns=columns,
            default_columns=DEFAULT_COLUMNS,
            data=flattened_dicts,
            logger_description="Products",
        )