@@ -1168,16 +1168,13 @@ def _escape_col_name(columns, col_name, extra):
11681168 return col_name
11691169
11701170
1171- def to_unindexed_series (x , name = None , native_namespace = None ):
1172- """Assuming x is list-like or even an existing Series, returns a new Series (with
1173- its index reset if pandas-like). Stripping the index from existing pd.Series is
1174- required to get things to match up right in the new DataFrame we're building.
1175- """
1171+ def to_named_series (x , name = None , native_namespace = None ):
1172+ """Assuming x is list-like or even an existing Series, returns a new Series named `name`."""
11761173 # With `pass_through=True`, the original object will be returned if unable to convert
11771174 # to a Narwhals Series.
11781175 x = nw .from_native (x , series_only = True , pass_through = True )
11791176 if isinstance (x , nw .Series ):
1180- return nw . maybe_reset_index ( x ) .rename (name )
1177+ return x .rename (name )
11811178 elif native_namespace is not None :
11821179 return nw .new_series (name = name , values = x , native_namespace = native_namespace )
11831180 else :
@@ -1306,7 +1303,7 @@ def process_args_into_dataframe(
13061303 length ,
13071304 )
13081305 )
1309- df_output [col_name ] = to_unindexed_series (
1306+ df_output [col_name ] = to_named_series (
13101307 real_argument , col_name , native_namespace
13111308 )
13121309 elif not df_provided :
@@ -1343,7 +1340,7 @@ def process_args_into_dataframe(
13431340 )
13441341 else :
13451342 col_name = str (argument )
1346- df_output [col_name ] = to_unindexed_series (
1343+ df_output [col_name ] = to_named_series (
13471344 df_input .get_column (argument ), col_name
13481345 )
13491346 # ----------------- argument is likely a column / array / list.... -------
@@ -1362,7 +1359,7 @@ def process_args_into_dataframe(
13621359 argument .name is not None
13631360 and argument .name in df_input .columns
13641361 and (
1365- to_unindexed_series (
1362+ to_named_series (
13661363 argument , argument .name , native_namespace
13671364 )
13681365 == df_input .get_column (argument .name )
@@ -1380,7 +1377,7 @@ def process_args_into_dataframe(
13801377 % (field , len_arg , str (list (df_output .keys ())), length )
13811378 )
13821379
1383- df_output [str (col_name )] = to_unindexed_series (
1380+ df_output [str (col_name )] = to_named_series (
13841381 x = argument ,
13851382 name = str (col_name ),
13861383 native_namespace = native_namespace ,
0 commit comments