Teradata Package for Python Function Reference | 17.10 - __getitem__ - Teradata Package for Python
Teradata® Package for Python Function Reference
- Product
- Teradata Package for Python
- Release Number
- 17.10
- Published
- April 2022
- Language
- English (United States)
- Last Update
- 2022-08-19
- 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.