<commit_before>import os
import shutil

import bcolz
import pandas as pd


def merge_bundles(zsource, ztarget):
    """
    Merge
    Parameters
    ----------
    zsource
    ztarget

    Returns
    -------

    """
    # TODO: find a way to do this iteratively instead of in-memory
    df_source = zsource.todataframe()
    df_target = ztarget.todataframe()

    df = pd.concat(
        [df_source, df_target], ignore_index=True
    )  # type: pd.DataFrame
    df.drop_duplicates(inplace=True)
    df.set_index(['date', 'symbol'], drop=False, inplace=True)

    dirname = os.path.basename(ztarget.rootdir)
    bak_dir = ztarget.rootdir.replace(dirname, '.{}'.format(dirname))
    os.rename(ztarget.rootdir, bak_dir)

    z = bcolz.ctable.fromdataframe(df=df, rootdir=ztarget.rootdir)
    shutil.rmtree(bak_dir)
    return z
<commit_msg>BUG: marketplace os.rename -> shutil.move<commit_after>import os
import shutil

import bcolz
import pandas as pd


def merge_bundles(zsource, ztarget):
    """
    Merge
    Parameters
    ----------
    zsource
    ztarget

    Returns
    -------

    """
    # TODO: find a way to do this iteratively instead of in-memory
    df_source = zsource.todataframe()
    df_target = ztarget.todataframe()

    df = pd.concat(
        [df_source, df_target], ignore_index=True
    )  # type: pd.DataFrame
    df.drop_duplicates(inplace=True)
    df.set_index(['date', 'symbol'], drop=False, inplace=True)

    dirname = os.path.basename(ztarget.rootdir)
    bak_dir = ztarget.rootdir.replace(dirname, '.{}'.format(dirname))
    shutil.move(ztarget.rootdir, bak_dir)

    z = bcolz.ctable.fromdataframe(df=df, rootdir=ztarget.rootdir)
    shutil.rmtree(bak_dir)
    return z

{'fraction_non_alphanumeric': 0.12939110070257612, 'fraction_numerical': 0.0, 'mean_word_length': 2.9377880184331797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5514749', 'n_tokens_mistral': 611, 'n_tokens_neox': 591, 'n_words': 119}