get_data_types

In [ ]:
get_data_types(expr: str = "",
               column: str = "",
               table_name: str = "",
               schema: str = "public",
               usecols: list = [],)

Returns the data types of the input relation's columns. It might create a temporary table during the process.

Parameters

Name Type Optional Description
expr
str
An expression in pure SQL. If empty, the parameter 'table_name' must be defined.
column
str
If not empty, it will return only the data type of the input column if it is in the relation.
table_name
str
Input table Name.
schema
str
Table schema.
usecols
list
List of columns to consider. This parameter can not be used if 'column' is defined.

Returns

list of tuples : The list of the different columns and their respective type.

Example

In [45]:
# returns the data type of multiple columns
from verticapy.utilities import *

get_data_types("SELECT pclass, embarked, AVG(survived) FROM public.titanic GROUP BY 1, 2")
Out[45]:
[['pclass', 'Integer'], ['embarked', 'Varchar(20)'], ['AVG', 'Float(22)']]
In [47]:
# returns the data type of one column
from verticapy.utilities import *

get_data_types("SELECT pclass, embarked, AVG(survived) FROM public.titanic GROUP BY 1, 2",
               column="pclass")
Out[47]:
'Integer'