def props_to_DataFrame(regionprops):
    r"""
    Returns a Pandas DataFrame containing all the scalar metrics for each
    region, such as volume, sphericity, and so on, calculated by
    ``regionprops_3D``.

    Parameters
    ----------
    regionprops : list
        This is a list of properties for each region that is computed
        by ``regionprops_3D``.  Because ``regionprops_3D`` returns data in
        the same ``list`` format as the ``regionprops`` function in **Skimage**
        you can pass in either.

    Returns
    -------
    DataFrame : Pandas DataFrame
        A Pandas DataFrame with each region corresponding to a row and each
        column corresponding to a key metric.  All the values for a given
        property (e.g. 'sphericity') can be obtained as
        ``val = df['sphericity']``.  Conversely, all the key metrics for a
        given region can be found with ``df.iloc[1]``.

    See Also
    --------
    props_to_image
    regionprops_3d
    """
    # Parse the regionprops list and pull out all props with scalar values
    metrics = []
    reg = regionprops[0]
    for item in reg.__dir__():
        if not item.startswith('_'):
            try:
                if sp.shape(getattr(reg, item)) == ():
                    metrics.append(item)
            except (TypeError, NotImplementedError, AttributeError):
                pass
    # Create a dictionary of all metrics that are simple scalar propertie
    d = {}
    for k in metrics:
        try:
            d[k] = sp.array([r[k] for r in regionprops])
        except ValueError:
            print('Error encountered evaluating ' + k + ' so skipping it')
    # Create pandas data frame an return
    df = DataFrame(d)
    return df
def props_to_DataFrame ( regionprops ) : metrics = [ ] reg = regionprops [ 0 ] for item in reg . __dir__ ( ) : if not item . startswith ( '_' ) : try : if sp . shape ( getattr ( reg , item ) ) == ( ) : metrics . append ( item ) except ( TypeError , NotImplementedError , AttributeError ) : pass d = { } for k in metrics : try : d [ k ] = sp . array ( [ r [ k ] for r in regionprops ] ) except ValueError : print ( 'Error encountered evaluating ' + k + ' so skipping it' ) df = DataFrame ( d ) return df
r"""
    Returns a Pandas DataFrame containing all the scalar metrics for each
    region, such as volume, sphericity, and so on, calculated by
    ``regionprops_3D``.

    Parameters
    ----------
    regionprops : list
        This is a list of properties for each region that is computed
        by ``regionprops_3D``.  Because ``regionprops_3D`` returns data in
        the same ``list`` format as the ``regionprops`` function in **Skimage**
        you can pass in either.

    Returns
    -------
    DataFrame : Pandas DataFrame
        A Pandas DataFrame with each region corresponding to a row and each
        column corresponding to a key metric.  All the values for a given
        property (e.g. 'sphericity') can be obtained as
        ``val = df['sphericity']``.  Conversely, all the key metrics for a
        given region can be found with ``df.iloc[1]``.

    See Also
    --------
    props_to_image
    regionprops_3d