Teradata Package for Python Function Reference on VantageCloud Lake - fillna - 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 on VantageCloud Lake
- Deployment
- VantageCloud
- Edition
- Lake
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.08
- Published
- November 2025
- ft:locale
- en-US
- ft:lastEdition
- 2025-12-05
- dita:id
- TeradataPython_FxRef_Lake_2000
- Product Category
- Teradata Vantage
- teradataml.dataframe.dataframe.DataFrame.fillna = fillna(self, value=None, columns=None, literal_value=False, partition_column=None)
- DESCRIPTION:
Method to replace the null values in a column with the value specified.
PARAMETERS:
value:
Required Argument.
Specifies the value(s) to replace the null values with. If value is a dict
then "columns" is ignored.
Note:
* To use pre-defined strings to replace the null value set "literal_value" to True.
Permitted Values:
* Pre-defined strings:
* 'MEAN' - Replace null value with the average of the values in the column.
* 'MODE' - Replace null value with the mode of the values in the column.
* 'MEDIAN' - Replace null value with the median of the values in the column.
* 'MIN' - Replace null value with the minimum of the values in the column.
* 'MAX' - Replace null value with the maximum of the values in the column.
Types: int, float, str, dict containing column names and value, list
columns:
Optional Argument.
Specifies the column names to perform the null value replacement. If "columns"
is None, then all the columns having null value and data type similar to
the data type of the value specified are considered.
Default Value: None
Types: str, tuple or list of str
literal_value:
Optional Argument.
Specifies whether the pre-defined strings passed to "value" should be treated
as literal or not.
Default Value: False
Types: bool
partition_column:
Optional Argument.
Specifies the column name to partition the data.
Default Value: None
Types: str
RETURNS:
teradataml DataFrame
RAISES:
TeradataMlException
EXAMPLES:
>>> load_example_data("dataframe", "sales")
>>> df = DataFrame("sales")
>>> df
Feb Jan Mar Apr datetime
accounts
Blue Inc 90.0 50.0 95.0 101.0 04/01/2017
Alpha Co 210.0 200.0 215.0 250.0 04/01/2017
Jones LLC 200.0 150.0 140.0 180.0 04/01/2017
Yellow Inc 90.0 NaN NaN NaN 04/01/2017
Orange Inc 210.0 NaN NaN 250.0 04/01/2017
Red Inc 200.0 150.0 140.0 NaN 04/01/2017
# Example 1: Populate null value in column 'Jan' and 'Mar'
# with the value specified as dictionary.
>>> df.fillna({"Jan": 123, "Mar":234})
accounts Feb Jan Mar Apr datetime
0 Blue Inc 90.0 50 95 101.0 17/01/04
1 Alpha Co 210.0 200 215 250.0 17/01/04
2 Jones LLC 200.0 150 140 180.0 17/01/04
3 Yellow Inc 90.0 123 234 NaN 17/01/04
4 Orange Inc 210.0 123 234 250.0 17/01/04
5 Red Inc 200.0 150 140 NaN 17/01/04
# Example 2: Populate the null value in 'Jan' column
# with minimum value in that column.
>>> df.fillna("Min", "Jan")
accounts Feb Jan Mar Apr datetime
0 Yellow Inc 90.0 50 NaN NaN 17/01/04
1 Jones LLC 200.0 150 140.0 180.0 17/01/04
2 Red Inc 200.0 150 140.0 NaN 17/01/04
3 Blue Inc 90.0 50 95.0 101.0 17/01/04
4 Alpha Co 210.0 200 215.0 250.0 17/01/04
5 Orange Inc 210.0 50 NaN 250.0 17/01/04
# Example 3: Populate the null value in 'pclass' and
# 'fare' column with mean value with partition
# column as 'sex'.
# Load the example data.
>>> load_example_data("teradataml", ["titanic"])
>>> df = DataFrame.from_table("titanic")
>>> df.fillna(value="mean", columns=["pclass", "fare"], partition_column="sex")
passenger survived pclass name sex age sibsp parch ticket fare cabin embarked
0 284 1 3 Dorking, Mr. Edward Arthur male 19.0 0 0 A/5. 10482 8.0500 None S
1 589 0 3 Gilinski, Mr. Eliezer male 22.0 0 0 14973 8.0500 None S
2 17 0 3 Rice, Master. Eugene male 2.0 4 1 382652 29.1250 None Q
3 282 0 3 Olsson, Mr. Nils Johan Goransson male 28.0 0 0 347464 7.8542 None S
4 608 1 1 Daniel, Mr. Robert Williams male 27.0 0 0 113804 30.5000 None S
5 404 0 3 Hakkarainen, Mr. Pekka Pietari male 28.0 1 0 STON/O2. 3101279 15.8500 None S
6 427 1 2 Clarke, Mrs. Charles V (Ada Maria Winfield) female 28.0 1 0 2003 26.0000 None S
7 141 0 3 Boulos, Mrs. Joseph (Sultana) female NaN 0 2 2678 15.2458 None C
8 610 1 1 Shutes, Miss. Elizabeth W female 40.0 0 0 PC 17582 153.4625 C125 S
9 875 1 2 Abelson, Mrs. Samuel (Hannah Wizosky) female 28.0 1 0 P/PP 3381 24.0000 None C