Add df data and tz type columns back into the same loc after type con… by evertlammerts · Pull Request #150 · duckdb/duckdb-python
Why not just
static void ReplaceDFColumn(PandasDataFrame &df, const char *col_name, idx_t idx, const py::handle &new_value) { df.attr("__setitem__")(col_name, new_value); }
* This is same as used in FrameFromNumpy.
In Python, we wouldn't perform two operations to replace a column (drop then insert in position). We'd just set it: df["mycol"] = ...., which preserves position.
... As a general rule, explicit "inplace" params in Pandas is something to avoid. See https://pandas.pydata.org/pdeps/0008-inplace-methods-in-pandas.html for a longer discussion of if.