How to use the pygsheets.utils.numericise_all function in pygsheets

To help you get started, we’ve selected a few pygsheets 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 nithinmurali / pygsheets / pygsheets / worksheet.py View on Github external
:param empty_value: value  used to indicate empty cell value
        :param start: top left cell of dataframe, if not set whole sheet will be fetched
        :param end: bottom right cell of dataframe, if not set whole sheet will be fetched

        :returns: pandas.Dataframe

        """
        if not DataFrame:
            raise ImportError("pandas")
        if start is not None and end is not None:
            values = self.get_values(start, end, include_empty=True)
        else:
            values = self.get_all_values(returnas='matrix', include_empty=True)

        if numerize:
            values = [numericise_all(row[:len(values[0])], empty_value) for row in values]

        if has_header:
            keys = values[0]
            values = [row[:len(values[0])] for row in values[1:]]
            df = DataFrame(values, columns=keys)
        else:
            df = DataFrame(values)

        if index_colum:
            if index_colum < 1 or index_colum > len(df.columns):
                raise ValueError("index_column %s not found" % index_colum)
            else:
                df.index = df[df.columns[index_colum - 1]]
                del df[df.columns[index_colum - 1]]
        return df
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
get value of wprksheet as a pandas dataframe

        :param head: colum head for df
        :param numerize: if values should be numerized
        :param empty_value: valued  used to indicate empty cell value

        :returns: pandas.Dataframe

        """
        if not DataFrame:
            raise ImportError("pandas")
        idx = head - 1
        values = self.all_values(returnas='matrix', include_empty=True)
        keys = list(''.join(values[idx]))
        if numerize:
            values = [numericise_all(row[:len(keys)], empty_value) for row in values[idx + 1:]]
        else:
            values = [row[:len(keys)] for row in values[idx + 1:]]
        return DataFrame(values, columns=keys)
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
And each of these dictionaries holding
            - the contents of subsequent rows of cells as values.

        Cell values are numericised (strings that can be read as ints
        or floats are converted).

        :param empty_value: determines empty cell's value
        :param head: determines wich row to use as keys, starting from 1
            following the numeration of the spreadsheet.

        :returns: a list of dict with header column values as head and rows as list
        """
        idx = head - 1
        data = self.all_values(returnas='matrix', include_empty=False)
        keys = data[idx]
        values = [numericise_all(row, empty_value) for row in data[idx + 1:]]
        return [dict(zip(keys, row)) for row in values]
github nithinmurali / pygsheets / pygsheets / worksheet.py View on Github external
And each of these dictionaries holding
            - the contents of subsequent rows of cells as values.

        Cell values are numericised (strings that can be read as ints
        or floats are converted).

        :param empty_value: determines empty cell's value
        :param head: determines wich row to use as keys, starting from 1
            following the numeration of the spreadsheet.

        :returns: a list of dict with header column values as head and rows as list
        """
        idx = head - 1
        data = self.get_all_values(returnas='matrix', include_empty=False)
        keys = data[idx]
        values = [numericise_all(row, empty_value) for row in data[idx + 1:]]
        return [dict(zip(keys, row)) for row in values]