Feb-08-2020, 02:07 AM
(This post was last modified: Feb-08-2020, 02:07 AM by new_to_python.)
Hello, I am new to pandas.
I got the list:
Out[41]:
state year pop
0 Ohio 2000 1.5
1 Ohio 2001 1.7
2 Ohio 2002 3.6
3 Nevada 2001 2.4
4 Nevada 2002 2.9
5 Nevada 2003 3.2
However, somebody else got the DataFrame with the headings in the order of: pop followed by state and then year. How come the order of the columns are different? Is it due to the version of pandas use? Does the order of the columns of DataFrame matter in pandas? How do I reorder the way the columns are displayed?
data = {'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada', 'Nevada', 'Nevada'], ...: 'year': [2000, 2001, 2002, 2001, 2002, 2003], ...: 'pop': [1.5, 1.7, 3.6, 2.4, 2.9, 3.2]} frame = pd.DataFrame(data)When I typed: frame
I got the list:
Out[41]:
state year pop
0 Ohio 2000 1.5
1 Ohio 2001 1.7
2 Ohio 2002 3.6
3 Nevada 2001 2.4
4 Nevada 2002 2.9
5 Nevada 2003 3.2
However, somebody else got the DataFrame with the headings in the order of: pop followed by state and then year. How come the order of the columns are different? Is it due to the version of pandas use? Does the order of the columns of DataFrame matter in pandas? How do I reorder the way the columns are displayed?