Create a DataFrame from Dict of Series
Dictionary of Series can be passed to form a DataFrame. The resultant index is the union of all the series indexes passed.
import pandas as pdd = {'one' : pd.Series([1, 2, 3], index=['a', 'b', 'c']),
'two' : pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd'])}df = pd.DataFrame(d)df| one | two | |
|---|---|---|
| a | 1.0 | 1 |
| b | 2.0 | 2 |
| c | 3.0 | 3 |
| d | NaN | 4 |
for the series one, there is no label ādā passed, but in the result, for the d label, NaN is appended with NaN.