Loading...

verticapy.vDataFrame.current_relation#

vDataFrame.current_relation(reindent: bool = True, split: bool = False) str#

Returns the current vDataFrame relation.

Parameters#

reindent: bool, optional

Reindent the text to be more readable.

split: bool, optional

Adds a split column __verticapy_split__ in the relation, which can be used to downsample the data.

Returns#

str

The formatted current vDataFrame relation.

Examples#

Let’s begin by importing VerticaPy.

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

Let us create a dummy dataset;

vdf = vp.vDataFrame({"val": [0, 10, 20]})
123
val
Integer
100%
10
210
320

Now we can check its current relation conveniently by:

print(vdf.current_relation())
((
   SELECT
     0 AS "val") UNION ALL (
   SELECT
     10 AS "val") UNION ALL (
   SELECT
     20 AS "val")) 
VERTICAPY_SUBTABLE

If we make any changes to the vDataFrame, those will also be reflected in the current_relation. For example, we normalize the data:

vdf.normalize()
Out[4]: 
None   val  
1    -1.0  
2     0.0  
3     1.0  
Rows: 3 | Column: val | Type: float

Let us observe the current relation now:

print(vdf.current_relation())
(
   SELECT
     ("val" - 10.0) / (10.0) AS "val" 
   FROM
 ((
   SELECT
     0 AS "val") UNION ALL (
   SELECT
     10 AS "val") UNION ALL (
   SELECT
     20 AS "val")) 
VERTICAPY_SUBTABLE) 
VERTICAPY_SUBTABLE

See also

vDataFrame.explain() : Information on how Vertica is computing the current vDataFrame relation.
vDataFrame.info() : Displays information about the different vDataFrame transformations