@@ -425,7 +425,7 @@ def _iloc_getitem_series_or_dataframe(
425425@typing .overload
426426def _iloc_getitem_series_or_dataframe (
427427 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 ]:
429429 ...
430430
431431
@@ -447,18 +447,29 @@ def _iloc_getitem_series_or_dataframe(
447447 return result_pd_df .iloc [0 ]
448448 elif isinstance (key , slice ):
449449 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 ]
460450 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+ )
462473 elif pd .api .types .is_list_like (key ):
463474 if len (key ) == 0 :
464475 return typing .cast (
@@ -491,11 +502,6 @@ def _iloc_getitem_series_or_dataframe(
491502 result = result .rename (original_series_name )
492503
493504 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- )
499505 elif callable (key ):
500506 raise NotImplementedError (
501507 f"iloc does not yet support indexing with a callable. { constants .FEEDBACK_LINK } "
0 commit comments