@@ -1666,11 +1666,12 @@ def from_records(
1666
1666
else :
1667
1667
try :
1668
1668
index_data = [arrays [arr_columns .get_loc (field )] for field in index ]
1669
+ except (KeyError , TypeError ):
1670
+ # raised by get_loc, see GH#29258
1671
+ result_index = index
1672
+ else :
1669
1673
result_index = ensure_index_from_sequences (index_data , names = index )
1670
-
1671
1674
exclude .update (index )
1672
- except Exception :
1673
- result_index = index
1674
1675
1675
1676
if any (exclude ):
1676
1677
arr_exclude = [x for x in exclude if x in arr_columns ]
@@ -3625,11 +3626,11 @@ def reindexer(value):
3625
3626
# GH 4107
3626
3627
try :
3627
3628
value = value .reindex (self .index )._values
3628
- except Exception as e :
3629
-
3630
- # duplicate axis
3629
+ except ValueError as err :
3630
+ # raised in MultiIndex.from_tuples, see test_insert_error_msmgs
3631
3631
if not value .index .is_unique :
3632
- raise e
3632
+ # duplicate axis
3633
+ raise err
3633
3634
3634
3635
# other
3635
3636
raise TypeError (
@@ -7796,7 +7797,8 @@ def f(x):
7796
7797
# TODO: combine with hasattr(result, 'dtype') further down
7797
7798
# hard since we don't have `values` down there.
7798
7799
result = np .bool_ (result )
7799
- except Exception as e :
7800
+ except TypeError as err :
7801
+ # e.g. in nanops trying to convert strs to float
7800
7802
7801
7803
# try by-column first
7802
7804
if filter_type is None and axis == 0 :
@@ -7826,7 +7828,7 @@ def f(x):
7826
7828
raise NotImplementedError (
7827
7829
"Handling exception with filter_type {f} not"
7828
7830
"implemented." .format (f = filter_type )
7829
- ) from e
7831
+ ) from err
7830
7832
with np .errstate (all = "ignore" ):
7831
7833
result = f (data .values )
7832
7834
labels = data ._get_agg_axis (axis )
0 commit comments