code: def test_add_datetime_attribute(self):
      seriesA = self.series1.add_datetime_attribute("day")
      assert seriesA.width == self.series1.width + 1
      assert set(
          seriesA.pd_dataframe()
          .iloc[:, seriesA.width - 1]
          .values.flatten()
      ) == set(range(1, 11))
      seriesB = self.series3.add_datetime_attribute("day", True)
      assert seriesB.width == self.series3.width + 31
      assert set(
          seriesB.pd_dataframe()
          .iloc[:, self.series3.width :]
          .values.flatten()
      ) == {0, 1}
      seriesC = self.series1.add_datetime_attribute("month", True)
      assert seriesC.width == self.series1.width + 12
      seriesD = TimeSeries.from_times_and_values(
          pd.date_range("20130206", "20130430"), range(84)
      )
      seriesD = seriesD.add_datetime_attribute("month", True)
      assert seriesD.width == 13
      assert sum(seriesD.values().flatten()) == sum(range(84)) + 84
      assert sum(seriesD.values()[:, 1 + 3]) == 30
      assert sum(seriesD.values()[:, 1 + 1]) == 23
  
      # test cyclic
      times_month = pd.date_range("20130101", "20140610")
  
      seriesE = TimeSeries.from_times_and_values(
          times_month, np.repeat(0.1, len(times_month))
      )
      seriesF = seriesE.add_datetime_attribute("day", cyclic=True)
  
      values_sin = seriesF.values()[:, 1]
      values_cos = seriesF.values()[:, 2]
  
      assert np.allclose(
          np.add(np.square(values_sin), np.square(values_cos)), 1
      )
  
      df = seriesF.pd_dataframe()
      df = df[df.index.day == 1]
      assert np.allclose(df["day_sin"].values, 0.2, atol=0.03)
      assert np.allclose(df["day_cos"].values, 0.97, atol=0.03)
  
imports: import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts.tests.test_timeseries import TestTimeSeries
label_desc: Use image node_id 16 for calling the TestTimeSeriesMultivariate obj's underlying member method code with example usage: obj.test_add_datetime_attribute() without return types