Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def validate(self, table):
column = table.columns[self._column_name]
if not isinstance(column.data_type, Number):
raise DataTypeError('Mean can only be applied to columns containing Number data.')
has_nulls = HasNulls(self._column_name).run(table)
if has_nulls:
warn_null_calculation(self, column)
def validate(self, table):
column = table.columns[self._column_name]
if not isinstance(column.data_type, Number):
raise DataTypeError('PercentileRank column must contain Number data.')
def get_computed_data_type(self, table):
return Number()
def get_aggregate_data_type(self, table):
return Number()
def validate(self, table):
column = table.columns[self._column_name]
if not isinstance(column.data_type, Number):
raise DataTypeError('StDev can only be applied to columns containing Number data.')
has_nulls = HasNulls(self._column_name).run(table)
if has_nulls:
warn_null_calculation(self, column)
def get_aggregate_data_type(self, table):
return Number()
def get_aggregate_data_type(self, table):
column = table.columns[self._column_name]
if (isinstance(column.data_type, Number) or
isinstance(column.data_type, Date) or
isinstance(column.data_type, DateTime)):
return column.data_type
def get_aggregate_data_type(self, table):
return Number()
column_names = list(table.column_names[:max_columns])
if columns_truncated:
column_names.append(ELLIPSIS)
widths = [len(n) for n in column_names]
number_formatters = []
formatted_data = []
# Determine correct number of decimal places for each Number column
for i, c in enumerate(table.columns):
if i >= max_columns:
break
if isinstance(c.data_type, Number):
max_places = max_precision(c[:max_rows])
number_formatters.append(make_number_formatter(max_places))
else:
number_formatters.append(None)
# Format data and display column widths
for i, row in enumerate(table.rows):
if i >= max_rows:
break
formatted_row = []
for j, v in enumerate(row):
if j >= max_columns:
v = ELLIPSIS
elif v is None:
:code:`120`.
:param output:
A file-like object to print to. Defaults to :code:`sys.stdout`.
:param printable:
If true, only printable characters will be outputed.
"""
y_label = label_column_name
label_column = self._columns[label_column_name]
# if not isinstance(label_column.data_type, Text):
# raise ValueError('Only Text data is supported for bar chart labels.')
x_label = value_column_name
value_column = self._columns[value_column_name]
if not isinstance(value_column.data_type, Number):
raise DataTypeError('Only Number data is supported for bar chart values.')
output = output
width = width
# Format numbers
decimal_places = utils.max_precision(value_column)
value_formatter = utils.make_number_formatter(decimal_places)
formatted_labels = []
for label in label_column:
formatted_labels.append(six.text_type(label))
formatted_values = []