_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q24800 | VerticalPyramid._get_separated_values | train | def _get_separated_values(self, secondary=False):
"""Separate values between odd and even series stacked"""
series = self.secondary_series if secondary else self.series
positive_vals = map(
sum,
zip(
*[
serie.safe_values for index, seri... | python | {
"resource": ""
} |
q24801 | VerticalPyramid._compute_box | train | def _compute_box(self, positive_vals, negative_vals):
"""Compute Y min and max"""
max_ = max(
max(positive_vals or [self.zero]),
max(negative_vals or [self.zero])
| python | {
"resource": ""
} |
q24802 | BaseGraph.setup | train | def setup(self, **kwargs):
"""Set up the transient state prior rendering"""
# Keep labels in case of map
if getattr(self, 'x_labels', None) is not None:
self.x_labels = list(self.x_labels)
if getattr(self, 'y_labels', None) is not None:
self.y_labels = list(self.y... | python | {
"resource": ""
} |
q24803 | rgb_to_hsl | train | def rgb_to_hsl(r, g, b):
"""Convert a color in r, g, b to a color in h, s, l"""
r = r or 0
g = g or 0
b = b or 0
r /= 255
g /= 255
b /= 255
max_ = max((r, g, b))
min_ = min((r, g, b))
d = max_ - min_
if not d:
h = 0
elif r is max_:
h = 60 * (g - b) / d
... | python | {
"resource": ""
} |
q24804 | hsl_to_rgb | train | def hsl_to_rgb(h, s, l):
"""Convert a color in h, s, l to a color in r, g, b"""
h /= 360
s /= 100
l /= 100
m2 = l * (s + 1) if l <= .5 else l + s - l * s
m1 = 2 * l - m2
def h_to_rgb(h):
h = h % 1
if 6 * h < 1:
return m1 + 6 * h * (m2 - m1)
if 2 * h < 1:... | python | {
"resource": ""
} |
q24805 | unparse_color | train | def unparse_color(r, g, b, a, type):
"""
Take the r, g, b, a color values and give back
a type css color string. This is the inverse function of parse_color
"""
if type == '#rgb':
# Don't lose precision on rgb shortcut
if r % 17 == 0 and g % 17 == 0 and b % 17 == 0:
retur... | python | {
"resource": ""
} |
q24806 | _adjust | train | def _adjust(hsl, attribute, percent):
"""Internal adjust function"""
hsl = list(hsl)
if attribute > 0:
hsl[attribute] = | python | {
"resource": ""
} |
q24807 | adjust | train | def adjust(color, attribute, percent):
"""Adjust an attribute of color by a percent"""
r, g, b, a, type = parse_color(color)
| python | {
"resource": ""
} |
q24808 | do_list | train | def do_list(lookup, term):
"""Matches term glob against short-name."""
space = lookup.keys()
matches = fnmatch.filter(space, | python | {
"resource": ""
} |
q24809 | do_find | train | def do_find(lookup, term):
"""Matches term glob against short-name, keywords and categories."""
space = defaultdict(list)
for name in lookup.keys():
space[name].append(name)
try:
iter_lookup = lookup.iteritems() # Python 2
except AttributeError:
iter_lookup = lookup.items... | python | {
"resource": ""
} |
q24810 | compile | train | def compile(expr, params=None):
"""
Force compilation of expression for the SQLite target | python | {
"resource": ""
} |
q24811 | HDFS.put_tarfile | train | def put_tarfile(
self,
hdfs_path,
local_path,
compression='gzip',
verbose=None,
overwrite=False,
):
"""
Write contents of tar archive to HDFS directly without having to
decompress it locally first
Parameters
----------
... | python | {
"resource": ""
} |
q24812 | WebHDFS.delete | train | def delete(self, hdfs_path, recursive=False):
"""Delete a file located at `hdfs_path`."""
| python | {
"resource": ""
} |
q24813 | _build_option_description | train | def _build_option_description(k):
"""Builds a formatted description of a registered option and prints it."""
o = _get_registered_option(k)
d = _get_deprecated_option(k)
buf = ['{} '.format(k)]
if o.doc:
doc = '\n'.join(o.doc.strip().splitlines())
else:
doc = 'No description ava... | python | {
"resource": ""
} |
q24814 | pp_options_list | train | def pp_options_list(keys, width=80, _print=False):
""" Builds a concise listing of available options, grouped by prefix """
from textwrap import wrap
from itertools import groupby
def pp(name, ks):
pfx = '- ' + name + '.[' if name else ''
ls = wrap(
', '.join(ks),
... | python | {
"resource": ""
} |
q24815 | all_equal | train | def all_equal(left, right, cache=None):
"""Check whether two objects `left` and `right` are equal.
Parameters
----------
left : Union[object, Expr, Node]
right : Union[object, Expr, Node]
cache : Optional[Dict[Tuple[Node, Node], bool]]
A dictionary indicating whether two Nodes are equal... | python | {
"resource": ""
} |
q24816 | SQLClient.table | train | def table(self, name, database=None):
"""
Create a table expression that references a particular table in the
database
Parameters
----------
name : string
database : string, optional
Returns
-------
table : TableExpr
| python | {
"resource": ""
} |
q24817 | SQLClient.sql | train | def sql(self, query):
"""
Convert a SQL query to an Ibis table expression
Parameters
----------
Returns
-------
table : TableExpr
"""
# Get the schema by adding a LIMIT 0 on to the end of the query. If
# there is already a limit in the qu... | python | {
"resource": ""
} |
q24818 | SQLClient.raw_sql | train | def raw_sql(self, query, results=False):
"""
Execute a given query string. Could have unexpected results if the
query modifies the behavior of the session in a way unknown to Ibis; be
careful.
Parameters
----------
query : string
DML or DDL statement
... | python | {
"resource": ""
} |
q24819 | SQLClient.execute | train | def execute(self, expr, params=None, limit='default', **kwargs):
"""
Compile and execute Ibis expression using this backend client
interface, returning results in-memory in the appropriate object type
Parameters
----------
expr : Expr
limit : int, default None
... | python | {
"resource": ""
} |
q24820 | SQLClient.compile | train | def compile(self, expr, params=None, limit=None):
"""
Translate expression to one or more queries according to backend target
Returns
-------
output : single query or list of queries
| python | {
"resource": ""
} |
q24821 | SQLClient.explain | train | def explain(self, expr, params=None):
"""
Query for and return the query plan associated with the indicated
expression or SQL query.
Returns
-------
plan : string
"""
if isinstance(expr, ir.Expr):
context = self.dialect.make_context(params=par... | python | {
"resource": ""
} |
q24822 | Database.table | train | def table(self, name):
"""
Return a table expression referencing a table in this database
Returns
-------
table : TableExpr
"""
| python | {
"resource": ""
} |
q24823 | cleanup | train | def cleanup(test_data, udfs, tmp_data, tmp_db):
"""Cleanup Ibis test data and UDFs"""
con = make_ibis_client(ENV)
if udfs:
# this comes before test_data bc the latter clobbers this too
| python | {
"resource": ""
} |
q24824 | sub_for | train | def sub_for(expr, substitutions):
"""Substitute subexpressions in `expr` with expression to expression
mapping `substitutions`.
Parameters
----------
expr : ibis.expr.types.Expr
An Ibis expression
substitutions : List[Tuple[ibis.expr.types.Expr, ibis.expr.types.Expr]]
A mapping ... | python | {
"resource": ""
} |
q24825 | has_reduction | train | def has_reduction(expr):
"""Does `expr` contain a reduction?
Parameters
----------
expr : ibis.expr.types.Expr
An ibis expression
Returns
-------
truth_value : bool
Whether or not there's at least one reduction in `expr`
Notes
-----
The ``isinstance(op, ops.Tab... | python | {
"resource": ""
} |
q24826 | find_source_table | train | def find_source_table(expr):
"""Find the first table expression observed for each argument that the
expression depends on
Parameters
----------
expr : ir.Expr
Returns
-------
table_expr : ir.TableExpr
Examples
--------
>>> import ibis
>>> t = ibis.table([('a', 'double'... | python | {
"resource": ""
} |
q24827 | flatten_predicate | train | def flatten_predicate(expr):
"""Yield the expressions corresponding to the `And` nodes of a predicate.
Parameters
----------
expr : ir.BooleanColumn
Returns
-------
exprs : List[ir.BooleanColumn]
Examples
--------
>>> import ibis
>>> t = ibis.table([('a', 'int64'), ('b', '... | python | {
"resource": ""
} |
q24828 | is_reduction | train | def is_reduction(expr):
"""Check whether an expression is a reduction or not
Aggregations yield typed scalar expressions, since the result of an
aggregation is a single value. When creating an table expression
containing a GROUP BY equivalent, we need to be able to easily check
that we are looking ... | python | {
"resource": ""
} |
q24829 | Substitutor._substitute | train | def _substitute(self, expr, mapping):
"""Substitute expressions with other expressions.
Parameters
----------
expr : ibis.expr.types.Expr
mapping : Mapping[ibis.expr.operations.Node, ibis.expr.types.Expr]
Returns
-------
ibis.expr.types.Expr
"""
... | python | {
"resource": ""
} |
q24830 | literal | train | def literal(value, type=None):
"""Create a scalar expression from a Python value.
Parameters
----------
value : some Python basic type
A Python value
type : ibis type or string, optional
An instance of :class:`ibis.expr.datatypes.DataType` or a string
indicating the ibis typ... | python | {
"resource": ""
} |
q24831 | sequence | train | def sequence(values):
"""
Wrap a list of Python values as an Ibis sequence type
Parameters
----------
values : list | python | {
"resource": ""
} |
q24832 | param | train | def param(type):
"""Create a parameter of a particular type to be defined just before
execution.
Parameters
----------
type : dt.DataType
The type of the unbound parameter, e.g., double, int64, date, etc.
Returns
-------
ScalarExpr
Examples
--------
>>> import ibis... | python | {
"resource": ""
} |
q24833 | Expr.visualize | train | def visualize(self, format='svg'):
"""Visualize an expression in the browser as an SVG image.
Parameters
----------
format : str, optional
Defaults to ``'svg'``. Some additional formats are
``'jpeg'`` and ``'png'``. These are specified by the ``graphviz``
... | python | {
"resource": ""
} |
q24834 | Expr.pipe | train | def pipe(self, f, *args, **kwargs):
"""Generic composition function to enable expression pipelining.
Parameters
----------
f : function or (function, arg_name) tuple
If the expression needs to be passed as anything other than the first
argument to the function, pass ... | python | {
"resource": ""
} |
q24835 | Expr.execute | train | def execute(self, limit='default', params=None, **kwargs):
"""
If this expression is based on physical tables in a database backend,
execute it against that backend.
Parameters
----------
limit : integer or None, default 'default'
| python | {
"resource": ""
} |
q24836 | Expr.compile | train | def compile(self, limit=None, params=None):
"""
Compile expression to whatever execution target, to verify
Returns
-------
compiled : value or list
query representation or | python | {
"resource": ""
} |
q24837 | ExprList.concat | train | def concat(self, *others):
"""
Concatenate expression lists
Returns
-------
combined : ExprList
"""
import ibis.expr.operations as ops
exprs = list(self.exprs())
for o in others:
| python | {
"resource": ""
} |
q24838 | ColumnExpr.to_projection | train | def to_projection(self):
"""
Promote this column expression to a table projection
"""
roots = self._root_tables()
if len(roots) > 1:
raise com.RelationError(
'Cannot convert array expression '
| python | {
"resource": ""
} |
q24839 | TableExpr.get_column | train | def get_column(self, name):
"""
Get a reference to a single column from the table
Returns
-------
column : array expression
"""
| python | {
"resource": ""
} |
q24840 | TableExpr.group_by | train | def group_by(self, by=None, **additional_grouping_expressions):
"""
Create an intermediate grouped table expression, pending some group
operation to be applied with it.
Examples
--------
>>> import ibis
>>> pairs = [('a', 'int32'), ('b', 'timestamp'), ('c', 'doub... | python | {
"resource": ""
} |
q24841 | TopKExpr.to_aggregation | train | def to_aggregation(
self, metric_name=None, parent_table=None, backup_metric_name=None
):
"""
Convert the TopK operation to a table aggregation
"""
op = self.op()
arg_table = find_base_table(op.arg)
by = op.by
if not isinstance(by, Expr):
... | python | {
"resource": ""
} |
q24842 | DayOfWeek.index | train | def index(self):
"""Get the index of the day of the week.
Returns
-------
IntegerValue
The index of the day | python | {
"resource": ""
} |
q24843 | DayOfWeek.full_name | train | def full_name(self):
"""Get the name of the day of the week.
Returns
-------
StringValue
The name of the day of the week
"""
| python | {
"resource": ""
} |
q24844 | indent | train | def indent(lines, spaces=4):
"""Indent `lines` by `spaces` spaces.
Parameters
----------
lines : Union[str, List[str]]
A string or list of strings to indent
spaces : int
The number of spaces to indent `lines`
Returns
-------
| python | {
"resource": ""
} |
q24845 | PythonToJavaScriptTranslator.local_scope | train | def local_scope(self):
"""Assign symbols to local variables.
"""
self.scope = self.scope.new_child()
try:
| python | {
"resource": ""
} |
q24846 | PythonToJavaScriptTranslator.visit_ListComp | train | def visit_ListComp(self, node):
"""Generate a curried lambda function
[x + y for x, y in [[1, 4], [2, 5], [3, 6]]]
becomes
[[1, 4], [2, 5], [3, 6]]].map(([x, y]) => x + y)
"""
try:
generator, = node.generators
except ValueError:
raise No... | python | {
"resource": ""
} |
q24847 | convert_timezone | train | def convert_timezone(obj, timezone):
"""Convert `obj` to the timezone `timezone`.
Parameters
----------
obj : datetime.date or datetime.datetime
Returns
-------
type(obj) | python | {
"resource": ""
} |
q24848 | ibis_schema_apply_to | train | def ibis_schema_apply_to(schema, df):
"""Applies the Ibis schema to a pandas DataFrame
Parameters
----------
schema : ibis.schema.Schema
df : pandas.DataFrame
Returns
-------
df : pandas.DataFrame
Notes
-----
Mutates `df`
"""
for column, dtype in schema.items():
... | python | {
"resource": ""
} |
q24849 | MySQLClient.table | train | def table(self, name, database=None, schema=None):
"""Create a table expression that references a particular a table
called `name` in a MySQL database called `database`.
Parameters
----------
name : str
The name of the table to retrieve.
database : str, optio... | python | {
"resource": ""
} |
q24850 | _generate_tokens | train | def _generate_tokens(pat: GenericAny, text: str) -> Iterator[Token]:
"""Generate a sequence of tokens from `text` that match `pat`
Parameters
----------
pat : compiled regex
The pattern to use for tokenization
text : str
The text to tokenize
"""
rules = _TYPE_RULES
keys... | python | {
"resource": ""
} |
q24851 | cast | train | def cast(
source: Union[DataType, str], target: Union[DataType, str], **kwargs
) -> DataType:
"""Attempts to implicitly cast from source dtype to target dtype"""
source, result_target = dtype(source), dtype(target)
if not castable(source, result_target, **kwargs):
| python | {
"resource": ""
} |
q24852 | verify | train | def verify(expr, params=None):
"""
Determine if expression can be successfully translated to execute on
MapD
"""
try:
| python | {
"resource": ""
} |
q24853 | connect | train | def connect(
uri=None,
user=None,
password=None,
host=None,
port=9091,
database=None,
protocol='binary',
execution_type=EXECUTION_TYPE_CURSOR,
):
"""Create a MapDClient for use with Ibis
Parameters could be
:param uri: str
:param user: str
:param password: str
:... | python | {
"resource": ""
} |
q24854 | create_udf_node | train | def create_udf_node(name, fields):
"""Create a new UDF node type.
Parameters
----------
name : str
Then name of the UDF node
fields : OrderedDict
Mapping of class member name to definition
Returns
-------
result : type
A new BigQueryUDFNode subclass | python | {
"resource": ""
} |
q24855 | execute_cross_join | train | def execute_cross_join(op, left, right, **kwargs):
"""Execute a cross join in pandas.
Notes
-----
We create a dummy column of all :data:`True` instances and use that as the
join key. This results in the desired Cartesian product behavior guaranteed
by cross join.
"""
# generate a uniqu... | python | {
"resource": ""
} |
q24856 | merge_pr | train | def merge_pr(
pr_num: int,
base_ref: str,
target_ref: str,
commit_title: str,
body: str,
pr_repo_desc: str,
original_head: str,
remote: str,
merge_method: str,
github_user: str,
password: str,
) -> None:
"""Merge a pull request."""
git_log = git[
"log",
... | python | {
"resource": ""
} |
q24857 | execute_series_lead_lag_timedelta | train | def execute_series_lead_lag_timedelta(
op, data, offset, default, aggcontext=None, **kwargs
):
"""An implementation of shifting a column relative to another one that is
in units of time rather than rows.
"""
# lagging adds time (delayed), leading subtracts time (moved up)
func = operator.add if ... | python | {
"resource": ""
} |
q24858 | MapDTable.load_data | train | def load_data(self, df):
"""
Wraps the LOAD DATA DDL statement. Loads data into an MapD table from
pandas.DataFrame or pyarrow.Table
Parameters
----------
df: pandas.DataFrame or pyarrow.Table
| python | {
"resource": ""
} |
q24859 | MapDTable.rename | train | def rename(self, new_name, database=None):
"""
Rename table inside MapD. References to the old table are no longer
valid.
Parameters
----------
new_name : string
database : string
Returns
-------
renamed : MapDTable
"""
m ... | python | {
"resource": ""
} |
q24860 | MapDClient.create_database | train | def create_database(self, name, owner=None):
"""
Create a new MapD database
Parameters
----------
name : string
Database name
| python | {
"resource": ""
} |
q24861 | MapDClient.drop_database | train | def drop_database(self, name, force=False):
"""
Drop an MapD database
Parameters
----------
name : string
Database name
force : boolean, default False
If False and there are any tables in this database, raises an
IntegrityError
"""
... | python | {
"resource": ""
} |
q24862 | MapDClient.create_user | train | def create_user(self, name, password, is_super=False):
"""
Create a new MapD user
Parameters
----------
name : string
User name
| python | {
"resource": ""
} |
q24863 | MapDClient.alter_user | train | def alter_user(
self, name, password=None, is_super=None, insert_access=None
):
"""
Alter MapD user parameters
Parameters
----------
name : string
User name
password : string
Password
is_super : bool
| python | {
"resource": ""
} |
q24864 | MapDClient.drop_user | train | def drop_user(self, name):
"""
Drop an MapD user
Parameters
----------
| python | {
"resource": ""
} |
q24865 | MapDClient.create_view | train | def create_view(self, name, expr, database=None):
"""
Create an MapD view from a table expression
Parameters
----------
name : string
expr : ibis TableExpr
database : string, default None
"""
ast | python | {
"resource": ""
} |
q24866 | MapDClient.drop_view | train | def drop_view(self, name, database=None):
"""
Drop an MapD view
Parameters
----------
name : string
database : string, default None
"""
| python | {
"resource": ""
} |
q24867 | MapDClient.create_table | train | def create_table(
self, table_name, obj=None, schema=None, database=None, max_rows=None
):
"""
Create a new table in MapD using an Ibis table expression.
Parameters
----------
table_name : string
obj : TableExpr or pandas.DataFrame, optional
If pass... | python | {
"resource": ""
} |
q24868 | MapDClient.drop_table | train | def drop_table(self, table_name, database=None, force=False):
"""
Drop an MapD table
Parameters
----------
table_name : string
database : string, default None (optional)
force : boolean, default False
Database may throw exception if table does not exist... | python | {
"resource": ""
} |
q24869 | MapDClient.truncate_table | train | def truncate_table(self, table_name, database=None):
"""
Delete all rows from, but do not drop, an existing table
Parameters
----------
table_name : string
database : string, default None (optional)
| python | {
"resource": ""
} |
q24870 | MapDClient.drop_table_or_view | train | def drop_table_or_view(self, name, database=None, force=False):
"""
Attempt to drop a relation that may be a view or table
"""
try:
self.drop_table(name, database=database)
except Exception as e:
| python | {
"resource": ""
} |
q24871 | MapDClient.load_data | train | def load_data(self, table_name, obj, database=None, **kwargs):
"""
Wraps the LOAD DATA DDL statement. Loads data into an MapD table by
physically moving data files.
Parameters
----------
table_name : string
obj: pandas.DataFrame or pyarrow.Table
| python | {
"resource": ""
} |
q24872 | connect | train | def connect(
project_id: Optional[str] = None,
dataset_id: Optional[str] = None,
credentials: Optional[google.auth.credentials.Credentials] = None,
) -> BigQueryClient:
"""Create a BigQueryClient for use with Ibis.
Parameters
----------
project_id : str
A BigQuery project id.
da... | python | {
"resource": ""
} |
q24873 | udf | train | def udf(f):
"""Create a SQLite scalar UDF from `f`
Parameters
----------
f
A callable object
Returns
-------
callable
A callable object that returns ``None`` if any of its inputs are
``None``.
"""
@functools.wraps(f)
def wrapper(*args):
| python | {
"resource": ""
} |
q24874 | _ibis_sqlite_regex_extract | train | def _ibis_sqlite_regex_extract(string, pattern, index):
"""Extract match of regular expression `pattern` from `string` at `index`.
Parameters
----------
string : str
pattern : str
index : int
Returns
-------
result : str or None | python | {
"resource": ""
} |
q24875 | _register_function | train | def _register_function(func, con):
"""Register a Python callable with a SQLite connection `con`.
Parameters
----------
func : callable
con : sqlalchemy.Connection
| python | {
"resource": ""
} |
q24876 | _register_aggregate | train | def _register_aggregate(agg, con):
"""Register a Python class that performs aggregation in SQLite.
Parameters
----------
agg : type
con : sqlalchemy.Connection
| python | {
"resource": ""
} |
q24877 | SQLiteClient.attach | train | def attach(self, name, path, create=False):
"""Connect another SQLite database file
Parameters
----------
name : string
Database name within SQLite
path : string
Path to sqlite3 file
create : boolean, optional
| python | {
"resource": ""
} |
q24878 | SQLiteClient.table | train | def table(self, name, database=None):
"""
Create a table expression that references a particular table in the
SQLite database
Parameters
----------
name : string
database : string, optional
name of the attached database that the table is located in.
... | python | {
"resource": ""
} |
q24879 | _sign | train | def _sign(translator, expr):
"""Workaround for missing sign function"""
op = | python | {
"resource": ""
} |
q24880 | hdfs_connect | train | def hdfs_connect(
host='localhost',
port=50070,
protocol='webhdfs',
use_https='default',
auth_mechanism='NOSASL',
verify=True,
session=None,
**kwds
):
"""Connect to HDFS.
Parameters
----------
host : str
Host name of the HDFS NameNode
port : int
NameN... | python | {
"resource": ""
} |
q24881 | _array_repeat | train | def _array_repeat(t, expr):
"""Is this really that useful?
Repeat an array like a Python list using modular arithmetic,
scalar subqueries, and PostgreSQL's ARRAY function.
This is inefficient if PostgreSQL allocates memory for the entire sequence
and the output column. A quick glance at PostgreSQL... | python | {
"resource": ""
} |
q24882 | _replace_interval_with_scalar | train | def _replace_interval_with_scalar(expr):
"""
Good old Depth-First Search to identify the Interval and IntervalValue
components of the expression and return a comparable scalar expression.
Parameters
----------
expr : float or expression of intervals
For example, ``ibis.interval(days=1) ... | python | {
"resource": ""
} |
q24883 | find_nodes | train | def find_nodes(expr, node_types):
"""Depth-first search of the expression tree yielding nodes of a given
type or set of types.
Parameters
----------
expr: ibis.expr.types.Expr
node_types: type or tuple of types
Yields
------
op: type
A | python | {
"resource": ""
} |
q24884 | roots | train | def roots(expr, types=(ops.PhysicalTable,)):
"""Yield every node of a particular type on which an expression depends.
Parameters
----------
expr : Expr
The expression to analyze
types : tuple(type), optional, default
(:mod:`ibis.expr.operations.PhysicalTable`,)
The node ... | python | {
"resource": ""
} |
q24885 | _get_args | train | def _get_args(op, name):
"""Hack to get relevant arguments for lineage computation.
We need a better way to determine the relevant arguments of an expression.
"""
# Could use multipledispatch here to avoid the pasta
if isinstance(op, ops.Selection):
assert name is not None, 'name is None'
... | python | {
"resource": ""
} |
q24886 | lineage | train | def lineage(expr, container=Stack):
"""Yield the path of the expression tree that comprises a column
expression.
Parameters
----------
expr : Expr
An ibis expression. It must be an instance of
:class:`ibis.expr.types.ColumnExpr`.
container : Container, {Stack, Queue}
Sta... | python | {
"resource": ""
} |
q24887 | traverse | train | def traverse(fn, expr, type=ir.Expr, container=Stack):
"""Utility for generic expression tree traversal
Parameters
----------
fn : Callable[[ir.Expr], Tuple[Union[Boolean, Iterable], Any]]
This function will be applied on each expressions, it must
return a tuple. The first element of th... | python | {
"resource": ""
} |
q24888 | adjoin | train | def adjoin(space: int, *lists: Sequence[str]) -> str:
"""Glue together two sets of strings using `space`."""
lengths = [max(map(len, x)) + space for x in lists[:-1]]
# not the last one
lengths.append(max(map(len, lists[-1])))
max_len = max(map(len, lists))
chains = (
itertools.chain(
... | python | {
"resource": ""
} |
q24889 | approx_equal | train | def approx_equal(a: Real, b: Real, eps: Real):
"""Return whether the difference between `a` and `b` is less than `eps`.
Parameters
----------
| python | {
"resource": ""
} |
q24890 | safe_index | train | def safe_index(elements: Sequence[T], value: T):
"""Find the location of `value` in `elements`, return -1 if `value` is
not found instead of raising ``ValueError``.
Parameters
----------
elements
value
Returns
-------
int
Examples
| python | {
"resource": ""
} |
q24891 | convert_unit | train | def convert_unit(value, unit, to):
"""Convert `value`, is assumed to be in units of `unit`, to units of `to`.
Parameters
----------
value : Union[numbers.Real, ibis.expr.types.NumericValue]
Returns
-------
Union[numbers.Integral, ibis.expr.types.NumericValue]
Examples
--------
... | python | {
"resource": ""
} |
q24892 | consume | train | def consume(iterator: Iterator[T], n: Optional[int] = None) -> None:
"""Advance the iterator n-steps ahead. If n is None, consume entirely."""
# Use functions that consume iterators at C speed.
if n is None:
# feed the entire iterator into a zero-length deque
| python | {
"resource": ""
} |
q24893 | arguments_from_signature | train | def arguments_from_signature(signature, *args, **kwargs):
"""Validate signature against `args` and `kwargs` and return the kwargs
asked for in the signature
Parameters
----------
args : Tuple[object...]
kwargs : Dict[str, object]
Returns
-------
Tuple[Tuple, Dict[str, Any]]
Ex... | python | {
"resource": ""
} |
q24894 | parameter_count | train | def parameter_count(funcsig):
"""Get the number of positional-or-keyword or position-only parameters in a
function signature.
Parameters
----------
funcsig : inspect.Signature
A UDF signature
Returns
-------
int
The | python | {
"resource": ""
} |
q24895 | udf.reduction | train | def reduction(input_type, output_type):
"""Define a user-defined reduction function that takes N pandas Series
or scalar values as inputs and produces one row of output.
Parameters
----------
input_type : List[ibis.expr.datatypes.DataType]
A list of the types found i... | python | {
"resource": ""
} |
q24896 | udf._grouped | train | def _grouped(input_type, output_type, base_class, output_type_method):
"""Define a user-defined function that is applied per group.
Parameters
----------
input_type : List[ibis.expr.datatypes.DataType]
A list of the types found in :mod:`~ibis.expr.datatypes`. The
... | python | {
"resource": ""
} |
q24897 | schema_from_table | train | def schema_from_table(table, schema=None):
"""Retrieve an ibis schema from a SQLAlchemy ``Table``.
Parameters
----------
table : sa.Table
Returns
-------
schema : ibis.expr.datatypes.Schema
An ibis schema corresponding to the types of the columns in `table`.
"""
schema = sc... | python | {
"resource": ""
} |
q24898 | invalidates_reflection_cache | train | def invalidates_reflection_cache(f):
"""Invalidate the SQLAlchemy reflection cache if `f` performs an operation
that mutates database or table metadata such as ``CREATE TABLE``,
``DROP TABLE``, etc.
Parameters
----------
f : callable
A method on :class:`ibis.sql.alchemy.AlchemyClient`
... | python | {
"resource": ""
} |
q24899 | AlchemyDatabaseSchema.table | train | def table(self, name):
"""
Return a table expression referencing a table in this schema
Returns
-------
table : TableExpr
"""
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.