Issue
I have two different functions which has two different dictionaries. First, I have to merge to dictionaries into one and then connect two dataframe.
import pandas as pd
output_df1 = {}
output_df1['diff_sum'] = 108
output_df1['cumsum'] = 232
out2 = {}
out2['carving'] = 1299
out2['bearing'] = 255
merge_dict = {**output_df1, **out2}
# upto this I'm able to do this
new_df = pd.DataFrame()
new_df['tata'] = merge_dict
new_df['diff_sum'] = 108
new_df
Getting result
Want this
How can I do it?
Solution
Try:
new_df = pd.DataFrame(merge_dict.values(), index=merge_dict, columns=["tata"])
print(new_df)
Prints:
tata
diff_sum 108
cumsum 232
carving 1299
bearing 255
Answered By - Andrej Kesely
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.