All Articles

Python

Concat DataFrame if not exists

def merge_df(df_left, df_right):
    """
    두 데이터 프레임을 존재하는지 확인 후 합쳐서 새로운 데이터 프레임을 생성 및 리턴

    Args:
        df_left (DataFrame): _description_
        df_right (DataFrame): _description_

    Returns:
        DataFrame: _description_
    """
    if df_right is None:
        # log('DataFrame df_right is null')
        if df_left is None:
            # log('DataFrame df_left is null')
            return None

    df_new = None
    if df_left is None:
        df_new = df_right
    else:
        df_new = pd.concat([df_left, df_right], ignore_index=True)
    return df_new

'Python' 카테고리의 다른 글

Shape Classcification  (0) 2022.01.30
Keras image resize raw bytes with size  (0) 2022.01.16
DataFrame to json utf8 한글  (0) 2022.01.07