import pandas as pd
...............
lease_list = context['pending_lease']
report_list = context['production_report']
# step1: Create two data frames and use panda merge to outer join two files on production_report_id
df_lease = pd.DataFrame([])
df_lease = df_lease.append(lease_list)
df_report = pd.DataFrame([])
df_report = df_report.append(report_list)
result = pd.merge(df_lease, df_report, on=list(report_list[0].keys())[0], how='outer')
result = result.fillna('')
# dataframe to list
pending_lease_prod = result.to_dict(orient='records')
..............
Reference:
https://pandas.pydata.org/pandas-docs/stable/merging.html
No comments:
Post a Comment