How to create a pandas DataFrame from two or more dictionaries having common keys? That is, to convert
DataFrame
d1 = {'a': 1} d2 = {'a': 3} ...
into a data frame with columns ['d1', 'd2', ...] , rows indexed as "a" , and values ββdefined by the corresponding dictionaries?
['d1', 'd2', ...]
"a"
import pandas as pd d1 = {'a': 1, 'b':2} d2 = {'a': 3, 'b':5} df = pd.DataFrame([d1, d2]).T df.columns = ['d{}'.format(i) for i, col in enumerate(df, 1)]
gives
In [40]: df Out[40]: d1 d2 a 1 3 b 2 5
Source: https://habr.com/ru/post/1202438/More articles:Docker Centos 7 easy_install supervisor ssl goes beyond proxy - dockerHow to create and use the iOS Framework for exchanging codes with extensions - iosFabricator capture and bitpack - gitMobile device ng-click and ng-touch - javascriptDigital Signature with AngularJS - angularjsLXML kills my CDATA sections - pythonVariable inside regex php - variablesHow to return an error from the Meteor.call method inside another Meteor.call - meteorList only shared parent directories for files - linuxdebugging an iOS 8 device with Xcode 5.1.1 - iosAll Articles