@requires_pandas
def test_to_data_frame():
    n_vert, n_times = 10, 5
    vertices = [np.arange(n_vert, dtype=np.int), np.empty(0, dtype=np.int)]
    data = rng.randn(n_vert, n_times)
    stc_surf = SourceEstimate(data, vertices=vertices, tmin=0, tstep=1,
                              subject='sample')
    stc_vol = VolSourceEstimate(data, vertices=vertices[0], tmin=0, tstep=1,
                                subject='sample')
    for stc in [stc_surf, stc_vol]:
        assert_raises(ValueError, stc.to_data_frame, index=['foo', 'bar'])
        for ncat, ind in zip([1, 0], ['time', ['subject', 'time']]):
            df = stc.to_data_frame(index=ind)
            assert_true(df.index.names == ind
                        if isinstance(ind, list) else [ind])
            assert_array_equal(df.values.T[ncat:], stc.data)
            # test that non-indexed data were present as categorial variables
            assert_true(all([c in ['time', 'subject'] for c in
                             df.reset_index().columns][:2]))
Exports a template as a file.
dataset/ETHPy150Open mne-tools/mne-python/mne/tests/test_source_estimate.py/test_to_data_frame--crossover with--dataset/ETHPy150Open Doist/todoist-python/todoist/api.py/TodoistAPI.export_template_as_file