code: def test_to_csv_multi_index(self):
      # see gh-6618
      df = DataFrame([1], columns=pd.MultiIndex.from_arrays([[1], [2]]))
  
      exp_rows = [",1", ",2", "0,1"]
      exp = tm.convert_rows_list_to_csv_str(exp_rows)
      assert df.to_csv() == exp
  
      exp_rows = ["1", "2", "1"]
      exp = tm.convert_rows_list_to_csv_str(exp_rows)
      assert df.to_csv(index=False) == exp
  
      df = DataFrame(
          [1],
          columns=pd.MultiIndex.from_arrays([[1], [2]]),
          index=pd.MultiIndex.from_arrays([[1], [2]]),
      )
  
      exp_rows = [",,1", ",,2", "1,2,1"]
      exp = tm.convert_rows_list_to_csv_str(exp_rows)
      assert df.to_csv() == exp
  
      exp_rows = ["1", "2", "1"]
      exp = tm.convert_rows_list_to_csv_str(exp_rows)
      assert df.to_csv(index=False) == exp
  
      df = DataFrame(
          [1], columns=pd.MultiIndex.from_arrays([["foo"], ["bar"]])
      )
  
      exp_rows = [",foo", ",bar", "0,1"]
      exp = tm.convert_rows_list_to_csv_str(exp_rows)
      assert df.to_csv() == exp
  
      exp_rows = ["foo", "bar", "1"]
      exp = tm.convert_rows_list_to_csv_str(exp_rows)
      assert df.to_csv(index=False) == exp
  
imports: import io
  import os
  import sys
  from zipfile import ZipFile
  from _csv import Error
  import numpy
  import pytest
  import pandas
  from pandas import DataFrame, Index, compat
  import pandas._testing
label_desc: Use image node_id 16 for calling the TestToCSV obj's underlying member method code with example usage: obj.test_to_csv_multi_index() without return types