def get_dataframe(self, ctx, dtype=None, sparse_fill_value=None):
        ctx_id = ctx if isinstance(ctx, int) else ctx.get_id()
        
        # if the builder's been finalized and there's a dataframe cached
        # return that without trying to convert it to a sparse dataframe
        # or changing the dtypes (dtype and sparse_fill_value are only
        # hints).
        try:
            return self._cached_dataframes[ctx_id]
        except __HOLE__:
            pass

        if dtype is None:
            dtype = self.dtype

        result_df = self._build_dataframe(ctx_id, dtype)

        if sparse_fill_value is None:
            sparse_fill_value = self.sparse_fill_value

        if sparse_fill_value is not None:
            # this doesn't always work depending on the actual dtype
            # the dataframe ends up being
            try:
                result_df = result_df.to_sparse(fill_value=sparse_fill_value)
            except TypeError:
                pass

        # try and infer types for any that are currently set to object
        return result_df.convert_objects()
dataset/ETHPy150Open manahl/mdf/mdf/builders/basic.py/DataFrameBuilder.get_dataframe