Skip to content

Commit 73b692f

Browse files
committed
fix ruff errors
1 parent 8582104 commit 73b692f

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

python/datafusion/dataframe.py

+13-15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from __future__ import annotations
2323

2424
import warnings
25+
from enum import Enum
2526
from typing import (
2627
TYPE_CHECKING,
2728
Any,
@@ -33,26 +34,22 @@
3334
overload,
3435
)
3536

37+
import pyarrow as pa
3638
from typing_extensions import deprecated
3739

40+
from datafusion import functions as f
41+
from datafusion._internal import DataFrame as DataFrameInternal
42+
from datafusion.expr import Expr, SortExpr, sort_or_default
3843
from datafusion.plan import ExecutionPlan, LogicalPlan
3944
from datafusion.record_batch import RecordBatchStream
4045

41-
import pyarrow as pa
42-
from datafusion import functions as f
43-
4446
if TYPE_CHECKING:
4547
import pathlib
4648
from typing import Callable, Sequence
4749

4850
import pandas as pd
4951
import polars as pl
5052

51-
from enum import Enum
52-
53-
from datafusion._internal import DataFrame as DataFrameInternal
54-
from datafusion.expr import Expr, SortExpr, sort_or_default
55-
5653

5754
# excerpt from deltalake
5855
# https://github.com/apache/datafusion-python/pull/981#discussion_r1905619163
@@ -868,14 +865,14 @@ def fill_null(self, value: Any, subset: list[str] | None = None) -> "DataFrame":
868865
869866
Examples:
870867
>>> df = df.fill_null(0) # Fill all nulls with 0 where possible
871-
>>> df = df.fill_null("missing", subset=["name", "category"]) # Fill string columns
868+
>>> # Fill nulls in specific string columns
869+
>>> df = df.fill_null("missing", subset=["name", "category"])
872870
873871
Notes:
874872
- Only fills nulls in columns where the value can be cast to the column type
875873
- For columns where casting fails, the original column is kept unchanged
876874
- For columns not in subset, the original column is kept unchanged
877875
"""
878-
879876
# Get columns to process
880877
if subset is None:
881878
subset = self.schema().names
@@ -916,23 +913,24 @@ def fill_nan(
916913
"""Fill NaN values in specified numeric columns with a value.
917914
918915
Args:
919-
value: Numeric value to replace NaN values with
920-
subset: Optional list of column names to fill. If None, fills all numeric columns.
916+
value: Numeric value to replace NaN values with.
917+
subset: Optional list of column names to fill. If None, fills all numeric
918+
columns.
921919
922920
Returns:
923-
DataFrame with NaN values replaced in numeric columns
921+
DataFrame with NaN values replaced in numeric columns.
924922
925923
Examples:
926924
>>> df = df.fill_nan(0) # Fill all NaNs with 0 in numeric columns
927-
>>> df = df.fill_nan(99.9, subset=["price", "score"]) # Fill specific columns
925+
>>> # Fill NaNs in specific numeric columns
926+
>>> df = df.fill_nan(99.9, subset=["price", "score"])
928927
929928
Notes:
930929
- Only fills NaN values in numeric columns (float32, float64)
931930
- Non-numeric columns are kept unchanged
932931
- For columns not in subset, the original column is kept unchanged
933932
- Value must be numeric (int or float)
934933
"""
935-
936934
if not isinstance(value, (int, float)):
937935
raise ValueError("Value must be numeric (int or float)")
938936

0 commit comments

Comments
 (0)