@@ -425,7 +425,7 @@ def _iloc_getitem_series_or_dataframe(
425
425
@typing .overload
426
426
def _iloc_getitem_series_or_dataframe (
427
427
series_or_dataframe : bigframes .dataframe .DataFrame , key
428
- ) -> Union [bigframes .dataframe .DataFrame , pd .Series ]:
428
+ ) -> Union [bigframes .dataframe .DataFrame , pd .Series , bigframes . core . scalar . Scalar ]:
429
429
...
430
430
431
431
@@ -447,18 +447,29 @@ def _iloc_getitem_series_or_dataframe(
447
447
return result_pd_df .iloc [0 ]
448
448
elif isinstance (key , slice ):
449
449
return series_or_dataframe ._slice (key .start , key .stop , key .step )
450
- elif isinstance (key , tuple ) and len (key ) == 0 :
451
- return series_or_dataframe
452
- elif isinstance (key , tuple ) and len (key ) == 1 :
453
- return _iloc_getitem_series_or_dataframe (series_or_dataframe , key [0 ])
454
- elif (
455
- isinstance (key , tuple )
456
- and isinstance (series_or_dataframe , bigframes .dataframe .DataFrame )
457
- and len (key ) == 2
458
- ):
459
- return series_or_dataframe .iat [key ]
460
450
elif isinstance (key , tuple ):
461
- raise pd .errors .IndexingError ("Too many indexers" )
451
+ if len (key ) > 2 or (
452
+ len (key ) == 2 and isinstance (series_or_dataframe , bigframes .series .Series )
453
+ ):
454
+ raise pd .errors .IndexingError ("Too many indexers" )
455
+
456
+ if len (key ) == 0 :
457
+ return series_or_dataframe
458
+
459
+ if len (key ) == 1 :
460
+ return _iloc_getitem_series_or_dataframe (series_or_dataframe , key [0 ])
461
+
462
+ # len(key) == 2
463
+ if isinstance (key [1 ], int ):
464
+ return series_or_dataframe .iat [key ]
465
+ elif isinstance (key [1 ], list ):
466
+ columns = series_or_dataframe .columns [key [1 ]]
467
+ return _iloc_getitem_series_or_dataframe (
468
+ series_or_dataframe [columns ], key [0 ]
469
+ )
470
+ raise NotImplementedError (
471
+ f"iloc does not yet support indexing with { key } . { constants .FEEDBACK_LINK } "
472
+ )
462
473
elif pd .api .types .is_list_like (key ):
463
474
if len (key ) == 0 :
464
475
return typing .cast (
@@ -491,11 +502,6 @@ def _iloc_getitem_series_or_dataframe(
491
502
result = result .rename (original_series_name )
492
503
493
504
return result
494
-
495
- elif isinstance (key , tuple ):
496
- raise NotImplementedError (
497
- f"iloc does not yet support indexing with a (row, column) tuple. { constants .FEEDBACK_LINK } "
498
- )
499
505
elif callable (key ):
500
506
raise NotImplementedError (
501
507
f"iloc does not yet support indexing with a callable. { constants .FEEDBACK_LINK } "
0 commit comments