Ejemplo n.º 1
0
    def to_string(self, nrows=NOTSET):
        """Convert to string

        Parameters
        ----------
        nrows : int
            Maximum number of rows to show.
            If it is None, all rows are shown.
        """
        if nrows is NOTSET:
            nrows = settings.formatting.get(nrows)

        if len(self) == 0:
            return "<empty Series of dtype={}>".format(self.dtype)

        if nrows is None:
            nrows = len(self)
        else:
            nrows = min(nrows, len(self))  # cap row count

        more_rows = len(self) - nrows

        # Prepare cells
        cols = OrderedDict([('', self.values_to_string(nrows=nrows))])
        # Format into a table
        return formatting.format(index=self.index,
                                 cols=cols,
                                 more_rows=more_rows)
Ejemplo n.º 2
0
    def to_string(self, nrows=NOTSET):
        """Convert to string

        Parameters
        ----------
        nrows : int
            Maximum number of rows to show.
            If it is None, all rows are shown.
        """
        if nrows is NOTSET:
            nrows = settings.formatting.get(nrows)

        str_dtype = self.dtype

        if len(self) == 0:
            return "<empty Series of dtype={}>".format(str_dtype)

        if nrows is None:
            nrows = len(self)
        else:
            nrows = min(nrows, len(self))  # cap row count

        more_rows = len(self) - nrows

        # Prepare cells
        cols = OrderedDict([('', self.values_to_string(nrows=nrows))])
        dtypes = OrderedDict([('', self.dtype)])
        # Format into a table
        output = formatting.format(index=self.index,
                                   cols=cols, dtypes=dtypes,
                                   more_rows=more_rows,
                                   series_spacing=True)
        return output + "\nName: {}, dtype: {}".format(self.name, str_dtype)\
            if self.name is not None else output + \
            "\ndtype: {}".format(str_dtype)