pythonsql 조작2

1689 단어 업무 관련
import pandas
import numpy as np
if __name__ == '__main__':


    ebay = "ebay_specific_required.csv"
    viomall = "viomall_pitem_specific.csv"
    ebay_df = pandas.DataFrame(
        pandas.read_csv(ebay, encoding="gbk", keep_default_na=True))
    viomall_df = pandas.DataFrame(
        pandas.read_csv(viomall, encoding="gbk", keep_default_na=True))
    product_sku = viomall_df.loc[:,"product_sku"].drop_duplicates()
    result = pandas.DataFrame({'product_sku': [],
                       'specify_name': [],
                       'specify_value': [],
                       'state':[] })
    for sku in product_sku:
        viomall_sku = viomall_df[viomall_df['product_sku'] == sku ]

        viomall_sku = viomall_sku.iloc[:,1:5]
        print(viomall_sku)
        category_sku = viomall_sku.loc[:, "ge_category1"].drop_duplicates()
        for category in category_sku:

            viomall_sku = viomall_sku[viomall_sku['ge_category1'] == category]
           # full_join = pandas.merge(viomall_sku,ebay_df,how="outer",on="ge_category1").drop_duplicates("product_sku")
            # 

            ebay_df = ebay_df[ebay_df['ge_category1'] == category]
            full_join = pandas.merge(viomall_sku, ebay_df, how="outer", on="specify_name")
            del full_join["ge_category1_x"]
            del full_join["ge_category1_y"]
            full_join.loc[:,"product_sku"] = sku
            result = result.append(full_join)
    result.to_csv("ebay_viomall_match.csv")

좋은 웹페이지 즐겨찾기