def test_concatenate_df_with_non_overlapping_cols(): d1 = DDF({'col1': np.arange(4), 'col2': np.arange(4)}) d2 = DDF({'col1': np.arange(2)}) d3 = d1.append(d2, axis=0) expected_col1 = np.array([0, 1, 2, 3, 0, 1]) expected_col2 = np.array([0, 1, 2, 3, np.nan, np.nan]) np.testing.assert_array_equal(d3['col1'], expected_col1) np.testing.assert_array_equal(d3['col2'], expected_col2)
def test_append_csv(tmpdir): path = str(tmpdir) + 'log.csv' data = DDF({'a': 1, 'b': 10}) append_csv(data, path) loaded = DDF.from_csv(path) assert loaded.equals(data) new_data = DDF({'a': 100, 'b': 101}) append_csv(new_data, path) loaded_appended = DDF.from_csv(path) appended = data.append(new_data) assert appended.equals(loaded_appended)
def test_appending_dfs_with_one_scalar_row(): df = DDF({'a': 0.10229005573016618}) other_df = DDF({'b': 0.10229005573016618}) df.append(other_df, axis=0)
def test_appending_new_df_with_new_cols(): d1 = DDF({'col1': np.arange(4), 'col2': np.arange(4)}) d2 = DDF({'col1': np.arange(2), 'col3': np.arange(2)}) d3 = d1.append(d2, axis=0) assert len(d3) == 6
def test_appending_with_timedeltas(): df = DDF({'delta': np.array([100, 'NaT'], dtype='timedelta64[ns]')}) other_df = DDF() df.append(other_df, axis=0)