【发布时间】:2020-09-08 09:40:24
【问题描述】:
我有 3 个数据帧 (df1, df2 and df3),每次我运行代码时,它们都被导入到 3 个 MySQL 表中。现在我正在尝试制作一个新的数据框来“监控”这 3 个数据框(或表)。
我的预期结果:
df - time_run - count_rows - count_columns
0 df1 - 12:00:23 - 100 - 9
1 df2 - 12:00:24 - 1500 - 8
2 df3 - 12:00:26 - 190 - 6
df 显示数据框的名称。 time_run 代表数据帧导出到 MySQL 的时间(在 HMS 中),count_rows 代表导出到 MySQL 的行数,count_columns 必须是导出到 MySQL 的列数。
这是我到现在为止的代码...:
#This is the last part of the code which sends the df's to MySQL.
df1.to_sql('table_df1', con = engine, if_exists = 'replace')
df2.to_sql('table_df2', con = engine, if_exists = 'replace')
df3.to_sql('table_df3', con = engine, if_exists = 'replace')
list_df = ['df1', 'df2', 'df3']
df_df = pd.DataFrame(list_df)
df_time_run =
df_count_rows =
df_count_columns =
the_dataframe = df_df.join([df_time_run, df_count_rows,df_count_columns])
我的目标是制作 4 个数据框(df_df, df_time_run, df_count_rows 和 df_count_columns)并将它们连接到 1 个数据框(the_dataframe)。然而,我只成功了df_df,然后我就卡住了......
【问题讨论】:
标签: python mysql pandas dataframe