@@ -322,7 +322,8 @@ def __init__(
322
322
elif _PANDAS_AVAILABLE and isinstance (data , pd .DataFrame ):
323
323
if not _PYARROW_AVAILABLE : # pragma: no cover
324
324
raise ImportError (
325
- "'pyarrow' is required for converting a pandas DataFrame to a polars DataFrame."
325
+ "'pyarrow' is required for converting a pandas DataFrame to a"
326
+ " polars DataFrame."
326
327
)
327
328
self ._df = pandas_to_pydf (data , columns = columns )
328
329
@@ -580,7 +581,8 @@ def _read_csv(
580
581
dtypes_dict = {name : dt for (name , dt ) in dtype_list }
581
582
if dtype_slice is not None :
582
583
raise ValueError (
583
- "cannot use glob patterns and unnamed dtypes as `dtypes` argument; Use dtypes: Mapping[str, Type[DataType]"
584
+ "cannot use glob patterns and unnamed dtypes as `dtypes` argument;"
585
+ " Use dtypes: Mapping[str, Type[DataType]"
584
586
)
585
587
from polars import scan_csv
586
588
@@ -609,7 +611,8 @@ def _read_csv(
609
611
return self ._from_pydf (scan .select (columns ).collect ()._df )
610
612
else :
611
613
raise ValueError (
612
- "cannot use glob patterns and integer based projection as `columns` argument; Use columns: List[str]"
614
+ "cannot use glob patterns and integer based projection as `columns`"
615
+ " argument; Use columns: List[str]"
613
616
)
614
617
615
618
projection , columns = handle_projection_columns (columns )
@@ -683,7 +686,8 @@ def _read_parquet(
683
686
return cls ._from_pydf (scan .select (columns ).collect ()._df )
684
687
else :
685
688
raise ValueError (
686
- "cannot use glob patterns and integer based projection as `columns` argument; Use columns: List[str]"
689
+ "cannot use glob patterns and integer based projection as `columns`"
690
+ " argument; Use columns: List[str]"
687
691
)
688
692
689
693
projection , columns = handle_projection_columns (columns )
@@ -775,7 +779,8 @@ def _read_ipc(
775
779
return scan .select (columns ).collect ()
776
780
else :
777
781
raise ValueError (
778
- "cannot use glob patterns and integer based projection as `columns` argument; Use columns: List[str]"
782
+ "cannot use glob patterns and integer based projection as `columns`"
783
+ " argument; Use columns: List[str]"
779
784
)
780
785
781
786
projection , columns = handle_projection_columns (columns )
@@ -819,7 +824,8 @@ def to_arrow(self) -> pa.Table:
819
824
"""
820
825
if not _PYARROW_AVAILABLE : # pragma: no cover
821
826
raise ImportError (
822
- "'pyarrow' is required for converting a polars DataFrame to an Arrow Table."
827
+ "'pyarrow' is required for converting a polars DataFrame to an Arrow"
828
+ " Table."
823
829
)
824
830
record_batches = self ._df .to_arrow ()
825
831
return pa .Table .from_batches (record_batches )
@@ -1437,7 +1443,8 @@ def write_parquet(
1437
1443
if use_pyarrow :
1438
1444
if not _PYARROW_AVAILABLE : # pragma: no cover
1439
1445
raise ImportError (
1440
- "'pyarrow' is required when using 'write_parquet(..., use_pyarrow=True)'."
1446
+ "'pyarrow' is required when using"
1447
+ " 'write_parquet(..., use_pyarrow=True)'."
1441
1448
)
1442
1449
1443
1450
tbl = self .to_arrow ()
@@ -1765,7 +1772,8 @@ def __getitem__(
1765
1772
return self ._from_pydf (self ._df .select (item ))
1766
1773
if item .dtype == bool :
1767
1774
warnings .warn (
1768
- "index notation '[]' is deprecated for boolean masks. Consider using 'filter'." ,
1775
+ "index notation '[]' is deprecated for boolean masks. Consider"
1776
+ " using 'filter'." ,
1769
1777
DeprecationWarning ,
1770
1778
)
1771
1779
return self ._from_pydf (self ._df .filter (pli .Series ("" , item ).inner ()))
@@ -1798,7 +1806,8 @@ def __setitem__(
1798
1806
self , key : str | list | tuple [Any , str | int ], value : Any
1799
1807
) -> None : # pragma: no cover
1800
1808
warnings .warn (
1801
- "setting a DataFrame by indexing is deprecated; Consider using DataFrame.with_column" ,
1809
+ "setting a DataFrame by indexing is deprecated; Consider using"
1810
+ " DataFrame.with_column" ,
1802
1811
DeprecationWarning ,
1803
1812
)
1804
1813
# df["foo"] = series
@@ -1817,7 +1826,8 @@ def __setitem__(
1817
1826
raise ValueError ("can only set multiple columns with 2D matrix" )
1818
1827
if value .shape [1 ] != len (key ):
1819
1828
raise ValueError (
1820
- "matrix columns should be equal to list use to determine column names"
1829
+ "matrix columns should be equal to list use to determine column"
1830
+ " names"
1821
1831
)
1822
1832
for (i , name ) in enumerate (key ):
1823
1833
self [name ] = value [:, i ]
@@ -3660,7 +3670,8 @@ def join(
3660
3670
"""
3661
3671
if how == "asof" : # pragma: no cover
3662
3672
warnings .warn (
3663
- "using asof join via DataFrame.join is deprecated, please use DataFrame.join_asof" ,
3673
+ "using asof join via DataFrame.join is deprecated, please use"
3674
+ " DataFrame.join_asof" ,
3664
3675
DeprecationWarning ,
3665
3676
)
3666
3677
if how == "cross" :
@@ -3842,7 +3853,8 @@ def with_column(self: DF, column: pli.Series | pli.Expr) -> DF:
3842
3853
"""
3843
3854
if isinstance (column , list ):
3844
3855
raise ValueError (
3845
- "`with_column` expects a single expression, not a list. Consider using `with_columns`"
3856
+ "`with_column` expects a single expression, not a list. Consider using"
3857
+ " `with_columns`"
3846
3858
)
3847
3859
if isinstance (column , pli .Expr ):
3848
3860
return self .with_columns ([column ])
@@ -6102,7 +6114,8 @@ def _select(self, columns: str | list[str]) -> GBSelection[DF]: # pragma: no co
6102
6114
One or multiple columns.
6103
6115
"""
6104
6116
warnings .warn (
6105
- "accessing GroupBy by index is deprecated, consider using the `.agg` method" ,
6117
+ "accessing GroupBy by index is deprecated, consider using the `.agg`"
6118
+ " method" ,
6106
6119
DeprecationWarning ,
6107
6120
)
6108
6121
if isinstance (columns , str ):
@@ -6218,7 +6231,8 @@ def groups(self) -> DF: # pragma: no cover
6218
6231
6219
6232
"""
6220
6233
warnings .warn (
6221
- "accessing GroupBy by index is deprecated, consider using the `.agg` method" ,
6234
+ "accessing GroupBy by index is deprecated, consider using the `.agg`"
6235
+ " method" ,
6222
6236
DeprecationWarning ,
6223
6237
)
6224
6238
return self ._dataframe_class ._from_pydf (
@@ -6377,11 +6391,13 @@ def _wrangle(x: Any) -> list:
6377
6391
)
6378
6392
else :
6379
6393
raise ValueError (
6380
- f"argument: { column_to_agg } not understood, have you passed a list of expressions?"
6394
+ f"argument: { column_to_agg } not understood, have you passed a list"
6395
+ " of expressions?"
6381
6396
)
6382
6397
else :
6383
6398
raise ValueError (
6384
- f"argument: { column_to_agg } not understood, have you passed a list of expressions?"
6399
+ f"argument: { column_to_agg } not understood, have you passed a list of"
6400
+ " expressions?"
6385
6401
)
6386
6402
6387
6403
return self ._dataframe_class ._from_pydf (
0 commit comments