Skip to content

Commit 9509f6d

Browse files
committed
fix ruff errors
1 parent 8582104 commit 9509f6d

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

python/datafusion/dataframe.py

+14-20
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,27 +34,21 @@
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
50-
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-
56-
5752
# excerpt from deltalake
5853
# https://github.com/apache/datafusion-python/pull/981#discussion_r1905619163
5954
class Compression(Enum):
@@ -868,14 +863,14 @@ def fill_null(self, value: Any, subset: list[str] | None = None) -> "DataFrame":
868863
869864
Examples:
870865
>>> df = df.fill_null(0) # Fill all nulls with 0 where possible
871-
>>> df = df.fill_null("missing", subset=["name", "category"]) # Fill string columns
866+
>>> # Fill nulls in specific string columns
867+
>>> df = df.fill_null("missing", subset=["name", "category"])
872868
873869
Notes:
874870
- Only fills nulls in columns where the value can be cast to the column type
875871
- For columns where casting fails, the original column is kept unchanged
876872
- For columns not in subset, the original column is kept unchanged
877873
"""
878-
879874
# Get columns to process
880875
if subset is None:
881876
subset = self.schema().names
@@ -910,29 +905,28 @@ def fill_null(self, value: Any, subset: list[str] | None = None) -> "DataFrame":
910905

911906
return self.select(*exprs)
912907

913-
def fill_nan(
914-
self, value: float | int, subset: list[str] | None = None
915-
) -> "DataFrame":
908+
def fill_nan(self, value: float | int, subset: list[str] | None = None) -> "DataFrame":
916909
"""Fill NaN values in specified numeric columns with a value.
917910
918911
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.
912+
value: Numeric value to replace NaN values with.
913+
subset: Optional list of column names to fill. If None, fills all numeric
914+
columns.
921915
922916
Returns:
923-
DataFrame with NaN values replaced in numeric columns
917+
DataFrame with NaN values replaced in numeric columns.
924918
925919
Examples:
926920
>>> 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
921+
>>> # Fill NaNs in specific numeric columns
922+
>>> df = df.fill_nan(99.9, subset=["price", "score"])
928923
929924
Notes:
930925
- Only fills NaN values in numeric columns (float32, float64)
931926
- Non-numeric columns are kept unchanged
932927
- For columns not in subset, the original column is kept unchanged
933928
- Value must be numeric (int or float)
934929
"""
935-
936930
if not isinstance(value, (int, float)):
937931
raise ValueError("Value must be numeric (int or float)")
938932

0 commit comments

Comments
 (0)