Teradata Package for Python Function Reference - __getitem__ - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.dataframe.dataframe.DataFrame.__getitem__ = __getitem__(self, key)
Return a column from the DataFrame or filter the DataFrame using an expression
The following operators are supported:
  comparison: ==, !=, <, <=, >, >=
  boolean: & (and), | (or), ~ (not), ^ (xor)
 
Operands can be python literals and instances of ColumnExpressions from the DataFrame
 
EXAMPLES:
  df = DataFrame('table')
 
  # filter the DataFrame df
  df[df.c1 > df.c2]
 
  df[df.c1 >= 1]
 
  df[df.c1 == 'string']
 
  df[1 != df.c2]
 
  df[~(1 < df.c2)]
 
  df[(df.c1 > 0) & (df.c2 > df.c1)]
 
  # retrieve column c1 from df
  df['c1']
 
PARAMETERS:
  key: A column name as a string or filter expression (ColumnExpression)
 
RETURNS:
  DataFrame or ColumnExpression instance
 
RAISES:
  1. KeyError   - If key is not found
  2. ValueError - When columns of different dataframes are given in ColumnExpression.