API: honor copy=True when passing dict to DataFrame by jbrockmendel · Pull Request #38939 · pandas-dev/pandas (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would copy matter here at all?
there are a couple of inter-twined issues here. the copy is necesary because we need df["A"] and df["B"] to not share data. We could do df = DataFrame({"A": tdi.values, "B": tdi.values.copy()})
isn't tdi supposed to be immutable?
yes, but thats kinda orthogonal (maybe 45°). e.g. in master
tdi = pd.timedelta_range("1 Day", periods=3)
df = pd.DataFrame(tdi)
df.iloc[0, 0] = pd.NaT
>>> tdi
TimedeltaIndex([NaT, '2 days', '3 days'], dtype='timedelta64[ns]', freq='D')
we need to always copy no?
i think we do something like this for dt64tz motivated by a similar immutability concern. ill see if that can be adapted