This function builds a list of columns of the data_frame argument used as arguments, either as str/int arguments or given as columns (pandas series type).
(args)
| 1111 | |
| 1112 | |
| 1113 | def _get_reserved_col_names(args): |
| 1114 | """ |
| 1115 | This function builds a list of columns of the data_frame argument used |
| 1116 | as arguments, either as str/int arguments or given as columns |
| 1117 | (pandas series type). |
| 1118 | """ |
| 1119 | df: nw.DataFrame = args["data_frame"] |
| 1120 | reserved_names = set() |
| 1121 | for field in args: |
| 1122 | if field not in all_attrables: |
| 1123 | continue |
| 1124 | names = args[field] if field in array_attrables else [args[field]] |
| 1125 | if names is None: |
| 1126 | continue |
| 1127 | for arg in names: |
| 1128 | if arg is None: |
| 1129 | continue |
| 1130 | elif isinstance(arg, str): # no need to add ints since kw arg are not ints |
| 1131 | reserved_names.add(arg) |
| 1132 | elif nw.dependencies.is_into_series(arg): |
| 1133 | arg_series = nw.from_native(arg, series_only=True) |
| 1134 | arg_name = arg_series.name |
| 1135 | if arg_name and arg_name in df.columns: |
| 1136 | in_df = (arg_series == df.get_column(arg_name)).all() |
| 1137 | if in_df: |
| 1138 | reserved_names.add(arg_name) |
| 1139 | elif arg is nw.maybe_get_index(df) and arg.name is not None: |
| 1140 | reserved_names.add(arg.name) |
| 1141 | |
| 1142 | return reserved_names |
| 1143 | |
| 1144 | |
| 1145 | def _is_col_list(columns, arg, is_pd_like, native_namespace): |
no test coverage detected