Convert Pythonic data to PyKX
This page documents converting python data types to PyKX data types via the pykx.toq
function.
pykx.toq
pykx.toq.from_*
methods should not be used directly
pykx.toq
or one of the pykx.K
subclassses should instead be used to convert a value into a
pykx.K
object. The pykx.toq.from_*
functions are automatically called by these higher-level
interfaces. They are documented here to explain what conversions from Python to q are supported,
and how they are performed.
Converts a Python object to a pykx.K
object.
pykx.toq
can be called to automatically select the appropriate pykx.toq.from_*
function
based on the type of the provided Python object. Refer to the documentation for each of the
pykx.toq.from_*
functions for more details about how each conversion works.
Instead of calling e.g. pykx.toq('qwerty', ktype=pykx.CharVector)
, one can instantiate the
desired type directly like so: pykx.CharVector('qwerty')
.
Examples:
>>> import pykx as kx
>>> import pandas as pd
>>> kx.toq('grok')
pykx.SymbolAtom(pykx.q('`grok'))
>>> kx.toq('grok', ktype=kx.CharVector)
pykx.CharVector(pykx.q('"grok"'))
>>> df = pd.DataFrame.from_dict({'x': [1, 2], 'y': ['a', 'b']})
>>> kx.toq(df)
pykx.Table(pykx.q('
x y
---
1 a
2 b
'))
>>> kx.toq(df, ktype={'x': kx.CharVector})
pykx.Table(pykx.q('
x y
------
,"1" a
,"2" b
'))
Parameters:
Name |
Type |
Description |
Default |
---|---|---|---|
|
|
A Python object which is to be
converted into a |
required |
|
|
Desired |
|
|
|
Cast the input Python object to the
closest conforming Python type before
converting to a |
|
`handle_nulls |
|
Convert |
|
Returns:
Type | Description |
---|---|
pykx.K |
The provided Python object as an analogous pykx.K object. |
from_arrow
method descriptor
from_arrow(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
See Also
Memory usage may spike during this function.
Normally converting from Python to q results in one copy of the data being made, but
because this function first converts to Pandas, it's possible for there to be a temporary
third copy made. See the PyArrow docs about converting to Pandas for more details
<https://arrow.apache.org/docs/python/pandas.html#memory-usage-and-zero-copy>
_.
Converts PyArrow arrays/tables into PyKX vectors/tables, respectively.
Conversions from PyArrow to q are performed by converting the PyArrow array/table to pandas
first, which avoids copying data when possible, then converting the resulting Pandas
data structure to q using from_pandas_series
or from_pandas_dataframe
as appropriate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Union['pa.Array', 'pa.Table']
|
The |
required |
ktype |
Optional[KType]
|
Desired |
None
|
cast |
bool
|
Unused. |
False
|
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Cannot convert PyArrow extension array to |
Returns:
Type | Description |
---|---|
Union[k.Vector, k.Table]
|
An instance of |
from_bytes
method descriptor
from_bytes(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a bytes
object into an instance of a string-like subclass of pykx.K
.
Parameters:
Name | Type | Description | Default | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
bytes
|
The |
required | ||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
ValueError
|
|
Returns:
Type | Description |
---|---|
Union[k.SymbolAtom, k.SymbolVector, k.CharAtom]
|
An instance of a |
from_callable
method descriptor
from_callable(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Inspection of the callable must be possible.
In order to determine how many parameters a provided callable has, PyKX calls
inspect.signature
on it. Some callables may not be introspectable in certain
implementations of Python. For example, in CPython, some built-in functions defined in C
provide no metadata about their arguments.
Converts a callable object into a q composition.
The resulting pykx.Composition
object works by keeping a reference to the provided callable
object. When the composition is called, it calls the Python callable with the arguments it received
as pykx.K
objects. Therefore, Python functions that are converted to q functions must be
able to handle receiving pykx.K
objects as arguments.
The return value of the provided Python callable will automatically be converted to a
pykx.K
object by having pykx.K
called on it. You can control how this conversion
happens by manually ensuring the return value of the function is a pykx.K
instance.
Because q does not have keyword arguments, all of the parameters of the Python callable are
treated as position parameters. *args
and **kwargs
are likewise treated as individual
parameters, which can be provided a pykx.Vector
and a pykx.Mapping
respectively.
Functions in q can have at most 8 parameters, so Python callables being converted to q must
abide by this limit. Parameters which have defaults set still count towards this limit. An
*args
parameters and a **kwargs
each count as a single parameter towards this limit.
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
Callable
|
A callable Python object that can take |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
ValueError
|
|
ValueError
|
|
Returns:
Type | Description |
---|---|
k.Composition
|
A |
from_datetime_date
method descriptor
from_datetime_date(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a datetime.date
into an instance of a subclass of pykx.TemporalFixedAtom
.
Parameters:
Name | Type | Description | Default | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
Any
|
The |
required | ||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||
cast |
bool
|
Apply a cast to a |
False
|
||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
NotImplementedError
|
The q datetime type is deprecated, so support for converting to it from Python has not been implemented. |
Returns:
Type | Description |
---|---|
k.TemporalFixedAtom
|
An instance of a subclass of |
from_datetime_datetime
method descriptor
from_datetime_datetime(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Setting environment variable PYKX_KEEP_LOCAL_TIMES
will result in the use of local time zones not UTC time.
By default this function will convert any datetime.datetime
objects with time zone
information to UTC before converting it to q
. If you set the environment vairable to 1,
true or True, then the objects with time zone information will not be converted to UTC and
instead will be converted to q
with no changes.
Converts a datetime.datetime
into an instance of a subclass of pykx.TemporalFixedAtom
.
Parameters:
Name | Type | Description | Default | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
Any
|
The |
required | ||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||
cast |
bool
|
Apply a cast to a |
False
|
||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
NotImplementedError
|
The q datetime type is deprecated, so support for converting to it from Python has not been implemented. |
Returns:
Type | Description |
---|---|
k.TemporalFixedAtom
|
An instance of a subclass of |
from_datetime_timedelta
method descriptor
from_datetime_timedelta(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a datetime.timedelta
into an instance of a subclass of pykx.TemporalSpanAtom
.
Parameters:
Name | Type | Description | Default | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
Any
|
The |
required | ||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||
cast |
bool
|
Apply a cast to a |
False
|
||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.TemporalSpanAtom
|
An instance of a subclass of |
from_dict
method descriptor
from_dict(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a dict
into a pykx.Dictionary
.
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
dict
|
The |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Convert |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.Dictionary
|
An instance of |
from_ellipsis
method descriptor
from_ellipsis(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Projection nulls are unwieldy.
If you aren't sure you know what you are doing, then you probably don't need to use a projection null.
Converts an Ellipsis
(...
) into a q projection null.
PyKX uses Python's ...
singleton to represent the q projection null, which is similar to
generic null (see from_none
), but indicates to q not just that there
is missing data, but that it should be filled in with the next q object that is applied onto
it.
This is how q creates function projections with later parameters specified. For instance,
the q function projection {x+y}[;7]
has an argument list of 2 q objects: a projection null,
followed by a long atom with a value of 7.
Because PyKX treats ...
as projection null, q projections can be created in Python like so:
>>> f = pykx.K(lambda x, y: x + y)
>>> projection = f(..., 7)
>>> projection(2)
pykx.LongAtom(pykx.q('9'))
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
Ellipsis
|
The |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.ProjectionNull
|
An instance of a subclass of |
from_fileno
method descriptor
from_fileno(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts an object with a fileno
attribute to a pykx.IntAtom
.
In q, int atoms that match open file descriptors can be called as if they were functions. Refer to https://code.kx.com/q/basics/handles/ for more information.
The fileno
attribute of x
can either be a Python int
, or a function that returns
an int
when called. The int
should represent an open file descriptor.
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
Any
|
An object with a |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.IntAtom
|
A |
from_float
method descriptor
from_float(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a float
into an instance of a subclass of pykx.NonIntegralNumericAtom
.
Parameters:
Name | Type | Description | Default | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
x |
Any
|
The |
required | ||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||
cast |
bool
|
Apply a cast to a Python |
False
|
||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.NonIntegralNumericAtom
|
An instance of a |
from_int
method descriptor
from_int(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts an int
into an instance of a subclass of pykx.IntegralNumericAtom
.
Parameters:
Name | Type | Description | Default | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
Any
|
The |
required | ||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||
cast |
bool
|
Apply cast to Python |
False
|
||||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
OverflowError
|
The provided |
The edges of the bounds have special meanings in q.
For pykx.LongAtom
, pykx.IntAtom
, and pykx.ShortAtom
, the lower bound of the
range is the null value for that type, one larger than that is the negative infinity for
that type, and the upper bound of the range is positive infinity for that type. An
exception will not be raised if int
objects with these values are provided. Refer to
the nulls and infinities PyKX documentation for more information about q nulls and
infinities, and how to handle them with PyKX.
Returns:
Type | Description |
---|---|
k.IntegralNumericAtom
|
An instance of a |
from_list
method descriptor
from_list(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
q lists are vectors
In q, a list (also called a "general list") is a vector of k objects. Non-list vectors (also called "typed vectors" or simply "vectors") are vectors of one particular type.
Converts a list
into an instance of a subclass of pykx.Vector
.
Parameters:
Name | Type | Description | Default | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
list
|
The |
required | ||||||||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
ValueError
|
Could not convert some elements of |
Returns:
Type | Description |
---|---|
k.Vector
|
An instance of a subclass of |
from_none
method descriptor
from_none(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts None
into a pykx.Identity
object.
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
None
|
The |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Unused. |
False
|
Returns:
Type | Description |
---|---|
k.Identity
|
A |
from_numpy_datetime64
method descriptor
from_numpy_datetime64(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a numpy.datetime64
into an instance of a subclass of pykx.TemporalFixedAtom
.
Parameters:
Name | Type | Description | Default | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
np.datetime64
|
The |
required | ||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
NotImplementedError
|
The q datetime type is deprecated, so support for converting to it from Python has not been implemented. |
Returns:
Type | Description |
---|---|
k.TemporalFixedAtom
|
An instance of a subclass of |
from_numpy_ndarray
method descriptor
from_numpy_ndarray(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Data is always copied when converting from Numpy to q if not using the PyKX Allocator.
While many conversions from q to Python types can be performed without incurring a copy, the reverse is not true. As mentioned in the q C API documentation, vectors in q store their metadata in a fixed memory location relative to their data, so the data for an array in Python's memory cannot be shared by q, since q would have to store the metadata in a memory location it has no ownership of.
Converts a numpy.ndarray
into a pykx.Vector
.
If the pykx.k_allocator
is enabled with the environment variable PYKX_ALLOCATOR
or if the
QARGS
environment variable contains --pykxalloc
, then 0 copy numpy array conversions
will be enabled for certain numpy.dtypes
s. This will allow for 0 copy conversions from numpy
arrays of a corresponding numpy.dtype
to pykx.NumericVector
s, and pykx.TimespanVector
s.
You can find the corresponding numpy.dtype
of a pykx.Vector
type by checking the
pykx.Vector._np_dtype
property of the type you want to create.
Note that when these 0 copy conversions are done both the numpy array and the resulting
pykx.Vector
refer to the same area of memory and changes made to one will be present in the
other object.
Because q only supports 1-dimensional arrays (vectors), Numpy arrays with more than 1 dimension will have all every level converted into a list of lists except for the lowest, for which each vector is converted to a q vector independently.
For example, in the following case, even though Numpy stores all of the data contiguously in
memory with a single numpy.ndarray
object wrapping it, q will store it as 3 vectors, with a
list containing them:
>>> np.arange(12).reshape(3, 4)
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> kx.K(np.arange(12).reshape(3, 4))
pykx.List(pykx.q('
0 1 2 3
4 5 6 7
8 9 10 11
'))
Numpy masked arrays can be used to indicate null data for integer types.
Parameters:
Name | Type | Description | Default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
np.ndarray
|
The |
required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cast |
bool
|
Apply a cast before converting to a |
False
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
handle_nulls |
bool
|
Convert |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
ValueError
|
Numpy array is not C-contiguous, which is required for |
Returns:
Type | Description |
---|---|
k.Vector
|
An instance of a subclass of |
from_numpy_timedelta64
method descriptor
from_numpy_timedelta64(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a numpy.timedelta64
into an instance of a subclass of pykx.TemporalSpanAtom
.
Parameters:
Name | Type | Description | Default | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
np.timedelta64
|
The |
required | ||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.TemporalSpanAtom
|
An instance of a subclass of |
from_pandas_dataframe
method descriptor
from_pandas_dataframe(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
See Also
Converts a pandas.DataFrame
into a pykx.Table
or pykx.KeyedTable
as appropriate.
The index and columns of the dataframe are each converted independently, and then the results of those conversions are used to assemble the resulting q table or keyed table.
If the dataframe does not have column names they will be generated: x, x1, .., x(n-1).
Parameters:
Name | Type | Description | Default | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
x |
pd.DataFrame
|
The |
required | ||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||
cast |
bool
|
Unused. |
False
|
||||||||
handle_nulls |
bool
|
Convert |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
Union[k.Table, k.KeyedTable]
|
An instance of |
from_pandas_index
method descriptor
from_pandas_index(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
See Also
Converts a pandas.Index
into a pykx.Vector
or pykx.Table
as appropriate.
Parameters:
Name | Type | Description | Default | ||||
---|---|---|---|---|---|---|---|
x |
pd.Index
|
The |
required | ||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||
cast |
bool
|
Unused. |
False
|
||||
handle_nulls |
bool
|
Convert |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
Union[k.Vector, k.Table]
|
An instance of |
from_pandas_series
method descriptor
from_pandas_series(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
See Also
Converts a pandas.Series
into an instance of a subclass of pykx.Vector
.
The given series is converted to a Numpy array, and then converted to a q vector as Numpy arrays generally are.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
pd.Series
|
The |
required |
ktype |
Optional[KType]
|
Desired |
None
|
cast |
bool
|
Unused. |
False
|
handle_nulls |
bool
|
Convert |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.Vector
|
An instance of a subclass of |
from_pathlib_path
method descriptor
from_pathlib_path(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a pathlib.Path
into a q handle symbol.
In q a symbol atom that begin with a :
is known as an "hsym", or handle symbol. These
symbols represent local or remote paths or resources.
Windows paths are reformatted as POSIX paths.
This function does not make the path absolute.
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
Path
|
The |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.SymbolAtom
|
An instance of a subclass of |
from_pykx_k
method descriptor
from_pykx_k(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a pykx.K
object into a pykx.K
object.
Parameters:
Name | Type | Description | Default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
k.K
|
A |
required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
LicenseException
|
Directly casting between |
TypeError
|
|
QError
|
Cannot cast the provided |
Returns:
Type | Description |
---|---|
k.K
|
The provided |
from_range
method descriptor
from_range(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a range
into an instance of a subclass of pykx.IntegralNumericVector
.
Parameters:
Name | Type | Description | Default | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
range
|
The |
required | ||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
OverflowError
|
The minimum or maximum value in the range is out of bounds for the selected
|
Returns:
Type | Description |
---|---|
k.IntegralNumericVector
|
An instance of a subclass of |
from_slice
method descriptor
from_slice(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a slice
into an instance of a subclass of pykx.IntegralNumericVector
.
Slice objects are used by Python for indexing. In q, indexing is done by applying a numeric
atom or vector to the object being indexed. As such, from_slice
works by converting the
given slice
into a pykx.IntegralNumericVector
, which can then be applied to an
indexable q object.
Parameters:
Name | Type | Description | Default | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
slice
|
The |
required | ||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
OverflowError
|
The minimum or maximum value in the slice is out of bounds for the selected
|
Returns:
Type | Description |
---|---|
k.IntegralNumericVector
|
An instance of a subclass of |
from_str
method descriptor
from_str(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a str
into an instance of a string-like subclass of pykx.K
.
Parameters:
Name | Type | Description | Default | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
str
|
The |
required | ||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
ValueError
|
|
Returns:
Type | Description |
---|---|
Union[k.CharAtom, k.CharVector, k.SymbolAtom]
|
An instance of a |
from_tuple
method descriptor
from_tuple(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
See Also
Converts a tuple
into an instance of a subclass of pykx.Vector
.
Parameters:
Name | Type | Description | Default | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x |
tuple
|
The |
required | ||||||||||||||||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||||||||||||||||
cast |
bool
|
Unused. |
False
|
||||||||||||||||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
ValueError
|
Could not convert some elements of |
Returns:
Type | Description |
---|---|
k.Vector
|
An instance of a subclass of |
from_uuid_UUID
method descriptor
from_uuid_UUID(
x, ktype=None, *, cast=False, handle_nulls=False, strings_as_char=False
)
Converts a uuid.UUID
into a pykx.GUIDAtom
.
Parameters:
Name | Type | Description | Default | ||||||
---|---|---|---|---|---|---|---|---|---|
x |
UUID
|
The |
required | ||||||
ktype |
Optional[KType]
|
Desired
|
None
|
||||||
cast |
bool
|
Unused. |
False
|
||||||
handle_nulls |
bool
|
Unused. |
False
|
Raises:
Type | Description |
---|---|
TypeError
|
Unsupported |
Returns:
Type | Description |
---|---|
k.GUIDAtom
|
An instance of |