Q:

Using pandas.dataframe.pivot_table with non-numeric, non-unique values

I am trying to call the pivot_table function on a pandas.dataframe object. This is an example of the object before calling the pivot_table function:
      Bid     Symb     Ask      DateTime
 0    201000  ESU6     201050   2016-06-19 18:59:58.337134544-05:00
 1    201025  ESU6     201075   2016-06-19 18:59:58.337134544-05:00
 2    201000  ESU6     201025   2016-06-19 18:59:59.611987128-05:00
 3    200975  ESU6     201025   2016-06-19 18:59:59.995825670-05:00

As you can see, there is a duplicate value in the DateTime column. I would like to call the pivot_table function result = object.pivot_table(columns='Symb', values=['Bid','Ask','DateTime'], index=result.index) in order to get the following dataframe object as a result:
          Bid     Ask     DateTime
 Symb     ESU6    ESU6    ESU6
 0        201000  201050  2016-06-19 18:59:58.337134544-05:00
 1        201025  201075  2016-06-19 18:59:58.337134544-05:00
 2        201000  201025  2016-06-19 18:59:59.611987128-05:00
 3        200975  201025  2016-06-19 18:59:59.995825670-05:00

However, DateTime has non-numeric values and thus does not get incorporated into the pivot_table function's output. Ultimately, I would like to get this as an end result:
                                      Bid.ESU6  Ask.ESU6
 DateTime
 2016-06-19 18:59:58.337134544-05:00  201000    201050
 2016-06-19 18:59:58.337134544-05:00  201025    201075
 2016-06-19 18:59:59.611987120-05:00  201000    201025
 2016-06-19 18:59:59.995825670-05:00  200975    201025

[Notice: The problem is that pivot_table will firstly not allow for non-unique indices (or rather, it will truncate the data such that the index is unique), so I can't just call result = object.pivot_table(columns='Symb', values=['Bid','Ask'], index=object['DateTime']). Further, if I keep integers as the index, it will not allow me to simply call result = object.pivot_table(columns='Symb', values=['Bid','Ask','DateTime'], index=object.index), because the DateTime column consists of non-numeric values, leading to a pivot_table result that simply excludes the DateTime column. Another work-around is to convert the DateTime to a numeric value that represents the datetime, then convert back, but this is resource-expensive and takes too much time, as my dataframe object has 100,000+ rows.]
Thank you in advance for the help!

A:

You can simple set new index after pivoting by values of column DateTime:
result = object.pivot_table(columns='Symb', values=['Bid','Ask'], index=object.index)
result.index = object.DateTime
#remove Multiindex in columns
result.columns = ['.'.join(col) for col in result.columns]
print (result)
                                     Bid.ESU6  Ask.ESU6
DateTime                                               
2016-06-19 18:59:58.337134544-05:00    201000    201050
2016-06-19 18:59:58.337134544-05:00    201025    201075
2016-06-19 18:59:59.611987128-05:00    201000    201025
2016-06-19 18:59:59.995825670-05:00    200975    201025

