@@ -143,20 +143,23 @@ def select(
143
143
* exprs : IntoExpr | Iterable [IntoExpr ],
144
144
** named_exprs : IntoExpr ,
145
145
) -> Self :
146
- exprs = tuple (flatten (exprs ))
147
- if exprs and all (isinstance (x , str ) for x in exprs ) and not named_exprs :
146
+ flat_exprs = tuple (flatten (exprs ))
147
+ if flat_exprs and all (isinstance (x , str ) for x in flat_exprs ) and not named_exprs :
148
148
# fast path!
149
149
try :
150
150
return self ._from_compliant_dataframe (
151
- self ._compliant_frame .simple_select (* exprs ),
151
+ self ._compliant_frame .simple_select (* flat_exprs ),
152
152
)
153
153
except Exception as e :
154
154
# Column not found is the only thing that can realistically be raised here.
155
- msg = f"{ e !s} \n \n Hint: Did you mean one of these columns: { self .columns } ?"
156
- raise ColumnNotFoundError (msg ) from e
155
+ available_columns = self .columns
156
+ missing_columns = [x for x in flat_exprs if x not in available_columns ]
157
+ raise ColumnNotFoundError .from_missing_and_available_column_names (
158
+ missing_columns , available_columns
159
+ ) from e
157
160
158
161
compliant_exprs , compliant_named_exprs = self ._flatten_and_extract (
159
- * exprs , ** named_exprs
162
+ * flat_exprs , ** named_exprs
160
163
)
161
164
return self ._from_compliant_dataframe (
162
165
self ._compliant_frame .select (* compliant_exprs , ** compliant_named_exprs ),
0 commit comments