我正在尝试基于一个内部联接合并两个数据帧,当我将这些数据帧联接在一起时,它们会删除有用的行。
import pandas as pd
import zipfile
read_advertiser_mapping = pd.read_csv("advertiserMarketMapping.csv",
encoding="utf-8")
print(read_advertiser_mapping.shape)
(37, 2)
read_dmc_static_zf = zipfile.ZipFile("DMC_Static_Conversions.zip")
read_dmc_static = pd.read_csv(read_dmc_static_zf.open(zipfile.ZipFile.namelist(read_dmc_static_zf)[0]),
skiprows=9, skipfooter=1, engine='python', encoding="utf-8")
print(read_dmc_static.shape)
(114421, 8)
merge_df = pd.merge(read_dmc_static, read_advertiser_mapping,
on='Advertiser')
print(merge_df.shape)
110944
writer_file = pd.ExcelWriter("file.xlsx", engine="xlsxwriter", datetime_format="YYYY-MM-DD")
x = merge_df.to_excel(writer_file)
writer_file.save()
writer_file.close()
文件 Advertiser Marketing 具有37行和 DMC_Static_Conversions 114421行,合并后应返回114303行,但仅 返回110944。
能否请您帮我知道我可以在哪里放置数据?