예제 #1
0
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)
예제 #2
0
파일: tools.py 프로젝트: SeamlessML/ddf
def append_csv(data, path):
    assert path.endswith('.csv')
    to_log = data if isinstance(data, DDF) else DDF(data)
    if os.path.isfile(path):
        current_log = DDF.from_csv(path)
        current_log = current_log.append(to_log, axis=0)
    else:
        current_log = to_log
    current_log.to_csv(path)
예제 #3
0
파일: test_ddf.py 프로젝트: SeamlessML/ddf
def test_saving_to_csv_by_default_does_not_save_index(tmpdir):
    save_path = str(tmpdir) + '/saved_df.csv'
    df = DDF({'col': np.arange(5)})
    df.to_csv(save_path)
    loaded_df = DDF.from_csv(save_path)
    assert 'Unnamed: 0' not in loaded_df