I'm trying to generate a dataframe using Pandas like this:
import pandas as pd
x='x'
y='y'
z='z'
Area='Area'
#len(coords_x)==len(coords_y)==len(coords_z)==64
#len(area[:,0])==18
my_dict = dict( x= np.asarray(coords_x),y= np.asarray(coords_y), z=
np.asarray(coords_z), Area= area[:,0])
df = pd.DataFrame.from_dict(my_dict, orient='index')
df=df.transpose()
writer = ExcelWriter('my_data.xlsx')
df.to_excel(writer,'Sheet1',index=False)
writer.save()
the problem is that I'm getting this order of columns: "y | x | z | Area"
How can I get this ordering "x | y | z | Area" as specified in the variable "my_dic" ? I tried the attribute df.columns=['x','y','z','Area'] but in vain. (I'm using python 2.7)