wesm/pandas — Issue #444: More convenient syntax for DataFrame constructor to declare order of columns?
Author: fperez
Created: 2011-12-05 04:14:09+00:00
State: open

I've searched the list, docs and issue list and didn't find this addressed, sorry if it was. It seems to me that right now, if I want to specify the order of my columns in new DataFrame built from existing Series, the only way to do it is to build a dict and pass the columns argument separately, with a redundant spelling of the column names:

```
df = pd.DataFrame(dict(m30_t10=splits_30, m15_t10=splits_15,
m30_m15=splits_m),
columns=['m30_t10', 'm15_t10','m30_m15'])
```

I'm wondering if a more convenient syntax could be devised for this operation. It seems that list-of-tuples already has different semantics, so the minimal change of the above doesn't work:

```
# This gives an error:
df3 = pd.DataFrame([('m30_t10', splits_30), ('m15_t10', splits_15),
('m30_m15', splits_m)])
```

It's unfortunate, b/c the above is incidentally a valid dict constructor:

```
# This is OK:
df3 = pd.DataFrame(dict([('m30_t10', splits_30), ('m15_t10', splits_15),
('m30_m15', splits_m)]))
```

But since a list is an inherently ordered data structure, it would be nice if it was accepted also as a constructor for DataFrame, carrying with it the implicit column order.