@@ -23,8 +23,6 @@ class StreamingDataFrameSchemaError(Exception):
23
23
Reveals an issue with inconsistant schemas.
24
24
"""
25
25
26
- pass
27
-
28
26
29
27
class StreamingDataFrame :
30
28
"""
@@ -273,9 +271,11 @@ def localf(a0=args[0]):
273
271
** kwargs_create ,
274
272
)
275
273
276
- def fct1 (st = st , args = args , chunksize = chunksize , kw = kwargs .copy ()):
274
+ def fct1 (
275
+ st = st , args = args , chunksize = chunksize , kw = kwargs .copy () # noqa: B008
276
+ ):
277
277
st .seek (0 )
278
- for r in pandas .read_json (
278
+ for r in pandas .read_json ( # noqa: UP028
279
279
st , * args , chunksize = chunksize , nrows = chunksize , lines = True , ** kw
280
280
):
281
281
yield r
@@ -293,8 +293,8 @@ def fct1(st=st, args=args, chunksize=chunksize, kw=kwargs.copy()):
293
293
** kwargs_create ,
294
294
)
295
295
296
- def fct2 (args = args , chunksize = chunksize , kw = kwargs .copy ()):
297
- for r in pandas .read_json (
296
+ def fct2 (args = args , chunksize = chunksize , kw = kwargs .copy ()): # noqa: B008
297
+ for r in pandas .read_json ( # noqa: UP028
298
298
* args , chunksize = chunksize , nrows = chunksize , ** kw
299
299
):
300
300
yield r
@@ -318,10 +318,10 @@ def fct2(args=args, chunksize=chunksize, kw=kwargs.copy()):
318
318
** kwargs_create ,
319
319
)
320
320
321
- def fct3 (st = st , args = args , chunksize = chunksize , kw = kwargs .copy ()):
321
+ def fct3 (st = st , args = args , chunksize = chunksize , kw = kwargs .copy ()): # noqa: B008
322
322
if hasattr (st , "seek" ):
323
323
st .seek (0 )
324
- for r in pandas .read_json (
324
+ for r in pandas .read_json ( # noqa: UP028
325
325
st , * args , chunksize = chunksize , nrows = chunksize , lines = True , ** kw
326
326
):
327
327
yield r
@@ -438,7 +438,7 @@ def __iter__(self):
438
438
elif self .check_schema :
439
439
if list (it .columns ) != sch [0 ]: # pylint: disable=E1136
440
440
raise StreamingDataFrameSchemaError ( # pragma: no cover
441
- "Column names are different after row {0}\n First chunk: {1}"
441
+ "Column names are different after row {0}\n First chunk: {1}" # noqa: UP030
442
442
"\n Current chunk: {2}" .format (rows , sch [0 ], list (it .columns ))
443
443
) # pylint: disable=E1136
444
444
if list (it .dtypes ) != sch [1 ]: # pylint: disable=E1136
@@ -454,7 +454,7 @@ def __iter__(self):
454
454
errdf = errdf [errdf ["diff" ]]
455
455
errdf .to_csv (tdf , sep = "," , index = False )
456
456
raise StreamingDataFrameSchemaError (
457
- "Column types are different after row {0}. You may use option "
457
+ "Column types are different after row {0}. You may use option " # noqa: UP030
458
458
'dtype={{"column_name": str}} to force the type on this column.'
459
459
"\n ---\n {1}" .format (rows , tdf .getvalue ())
460
460
)
@@ -502,9 +502,7 @@ def to_csv(self, path_or_buf=None, **kwargs) -> "StreamingDataFrame":
502
502
st = StringIO ()
503
503
close = False
504
504
elif isinstance (path_or_buf , str ):
505
- st = open ( # pylint: disable=R1732
506
- path_or_buf , "w" , encoding = kwargs .get ("encoding" )
507
- )
505
+ st = open (path_or_buf , "w" , encoding = kwargs .get ("encoding" )) # noqa: SIM115
508
506
close = True
509
507
else :
510
508
st = path_or_buf
@@ -537,7 +535,7 @@ def iterrows(self):
537
535
See :epkg:`pandas:DataFrame:iterrows`.
538
536
"""
539
537
for df in self :
540
- for it in df .iterrows ():
538
+ for it in df .iterrows (): # noqa: UP028
541
539
yield it
542
540
543
541
def head (self , n = 5 ) -> pandas .DataFrame :
@@ -579,7 +577,8 @@ def where(self, *args, **kwargs) -> "StreamingDataFrame":
579
577
"""
580
578
kwargs ["inplace" ] = False
581
579
return StreamingDataFrame (
582
- lambda : map (lambda df : df .where (* args , ** kwargs ), self ), ** self .get_kwargs ()
580
+ lambda : map (lambda df : df .where (* args , ** kwargs ), self ), # noqa: C417
581
+ ** self .get_kwargs (),
583
582
)
584
583
585
584
def sample (self , reservoir = False , cache = False , ** kwargs ) -> "StreamingDataFrame" :
@@ -608,7 +607,7 @@ def sample(self, reservoir=False, cache=False, **kwargs) -> "StreamingDataFrame"
608
607
df = sdf .to_df ()
609
608
return StreamingDataFrame .read_df (df , chunksize = df .shape [0 ])
610
609
return StreamingDataFrame (
611
- lambda : map (lambda df : df .sample (** kwargs ), self ),
610
+ lambda : map (lambda df : df .sample (** kwargs ), self ), # noqa: C417
612
611
** self .get_kwargs (),
613
612
stable = False ,
614
613
)
@@ -684,7 +683,7 @@ def drop(
684
683
if inplace :
685
684
raise NotImplementedError (f"drop is not implemented for inplace={ inplace } ." )
686
685
return StreamingDataFrame (
687
- lambda : map (
686
+ lambda : map ( # noqa: C417
688
687
lambda df : df .drop (
689
688
labels ,
690
689
axis = axis ,
@@ -706,7 +705,8 @@ def apply(self, *args, **kwargs) -> "StreamingDataFrame":
706
705
<pandas_streaming.df.dataframe.StreamingDataFrame>`.
707
706
"""
708
707
return StreamingDataFrame (
709
- lambda : map (lambda df : df .apply (* args , ** kwargs ), self ), ** self .get_kwargs ()
708
+ lambda : map (lambda df : df .apply (* args , ** kwargs ), self ), # noqa: C417
709
+ ** self .get_kwargs (),
710
710
)
711
711
712
712
def applymap (self , * args , ** kwargs ) -> "StreamingDataFrame" :
@@ -716,7 +716,7 @@ def applymap(self, *args, **kwargs) -> "StreamingDataFrame":
716
716
<pandas_streaming.df.dataframe.StreamingDataFrame>`.
717
717
"""
718
718
return StreamingDataFrame (
719
- lambda : map (lambda df : df .applymap (* args , ** kwargs ), self ),
719
+ lambda : map (lambda df : df .applymap (* args , ** kwargs ), self ), # noqa: C417
720
720
** self .get_kwargs (),
721
721
)
722
722
@@ -773,7 +773,7 @@ def _concath(self, others):
773
773
others = [others ]
774
774
775
775
def iterateh (self , others ):
776
- cols = tuple ([ self ] + others )
776
+ cols = ( self , * others )
777
777
for dfs in zip (* cols ):
778
778
nrows = [_ .shape [0 ] for _ in dfs ]
779
779
if min (nrows ) != max (nrows ):
@@ -1382,7 +1382,7 @@ def __init__(self, iter_creation, check_schema=True, stable=True):
1382
1382
)
1383
1383
if len (self .columns ) != 1 :
1384
1384
raise RuntimeError ( # pragma: no cover
1385
- f"A series can contain only one column not " f" { len (self .columns )!r} ."
1385
+ f"A series can contain only one column not { len (self .columns )!r} ."
1386
1386
)
1387
1387
1388
1388
def apply (self , * args , ** kwargs ) -> "StreamingDataFrame" :
@@ -1391,7 +1391,8 @@ def apply(self, *args, **kwargs) -> "StreamingDataFrame":
1391
1391
This function returns a @see cl StreamingSeries.
1392
1392
"""
1393
1393
return StreamingSeries (
1394
- lambda : map (lambda df : df .apply (* args , ** kwargs ), self ), ** self .get_kwargs ()
1394
+ lambda : map (lambda df : df .apply (* args , ** kwargs ), self ), # noqa: C417
1395
+ ** self .get_kwargs (),
1395
1396
)
1396
1397
1397
1398
def __add__ (self , value ):
0 commit comments