0

How to insert into a dataframe new date column with the following date: 2021-11-30

my question was closed with this answer : Add column with constant value to pandas dataframe

But this is about adding a new column not a new date column

Skittles
  • 109
  • 7
  • Do you use `df['new'] = pd.Timestamp('2021-11-30')` ? – jezrael Dec 02 '21 at 13:32
  • Yes, but I get this error: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy – Skittles Dec 02 '21 at 13:48
  • there is some filtration before creating `df['new'] = pd.Timestamp('2021-11-30')` ? If yes, need `.copy()` – jezrael Dec 02 '21 at 13:49
  • 1
    thank you worked by adding .copy() when slicing the dataframe with query() – Skittles Dec 02 '21 at 14:10

0 Answers0