I am creating an initial pandas framework to store the results generated by other codes: for example,
result = pd.DataFrame({'date': datelist, 'total': [0]*len(datelist),
'TT': [0]*len(datelist)})
with a datelistpredefined list. Then the other codes will give out a number for totaland TTfor each date, which I will keep in the frame result.
So, I want the first column to be date, the second totaland third TT. However, the pandas will automatically change the order in alphabetical order TT, date, totalto create. While I can manually reorder after this, I wonder if there is an easier way to achieve this in one step.
I thought I could do and
result = pd.DataFrame(np.transpose([datelist, [0]*l, [0]*l]),
columns = ['date', 'total', 'TT'])
but it somehow looks tiring too. Any other suggestions?
source
share