code: def test_truncate_datetime_dataframe_all_parts():
      """Test for truncate_datetime_dataframe, for all valid dateparts.
      Also only passes if `truncate_datetime_dataframe` method is idempotent.
      """
      x = datetime(2022, 3, 21, 9, 1, 15, 666)
      df = pd.DataFrame({"dt": [x], "foo": [np.nan]}, copy=False)
  
      result = df.truncate_datetime_dataframe("second")
      assert result.loc[0, "dt"] == datetime(2022, 3, 21, 9, 1, 15, 0)
      result = df.truncate_datetime_dataframe("minute")
      assert result.loc[0, "dt"] == datetime(2022, 3, 21, 9, 1)
      result = df.truncate_datetime_dataframe("HOUR")
      assert result.loc[0, "dt"] == datetime(2022, 3, 21, 9)
      result = df.truncate_datetime_dataframe("Day")
      assert result.loc[0, "dt"] == datetime(2022, 3, 21)
      result = df.truncate_datetime_dataframe("month")
      assert result.loc[0, "dt"] == datetime(2022, 3, 1)
      result = df.truncate_datetime_dataframe("yeaR")
      assert result.loc[0, "dt"] == datetime(2022, 1, 1)
  
file_path: pyjanitor/tests/functions/test_truncate_datetime.py
imports: from datetime import datetime
  import numpy
  import pandas
  import pytest
  from pandas.testing import assert_frame_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_truncate_datetime_dataframe_all_parts() without return types