I have a DataFrame test
with a DateTimeIndex and I want to create a copy and drop the frequency
on the copy. But the original test
also losses information about the frequency. I used test.copy(deep=True)
to make sure I make a deep copy.
import copy
import pandas as pd
dr = pd.date_range('2020-01-01', periods=10, freq='1H')
test = pd.DataFrame({'target':list(range(10))}, index=dr)
print(test.index.freq)
>>> <Hour>
_copy = test.copy(deep=True)
# _copy = copy.deepcopy(test)
print(test.index.freq)
>>> <Hour>
_copy.index.freq=None
print(test.index.freq)
>>> None # expectet output is <Hour>
In a second step I created my copy using copy.deepcopy(test)
but the result is still the same.
I am using pandas 1.3.3 and python 3.9.7.
Is there an option to create a copy not linked to the original?