I am new to pandas and was checking out Pandas.Dataframe. I realize that always I am creating a dataframe, a first column with no column title is created which is also the index column. For example the following code:
from collections import OrderedDict
table = OrderedDict((
("Item", ['Item0', 'Item0', 'Item1', 'Item1']),
('CType',['Gold', 'Bronze', 'Gold', 'Silver']),
('USD', ['1$', '2$', '3$', '4$']),
('EU', ['1€', '2€', '3€', '4€'])
))
df = pd.DataFrame(table)
Gives the result:
Item CType USD EU
0 Item0 Gold 1$ 1€
1 Item0 Bronze 2$ 2€
2 Item1 Gold 3$ 3€
3 Item1 Silver 4$ 4€
But the first column is not listed in the columns. Because if I execute len(df.columns)
I will get 4. Or print(list(df))
will list: ['Item', 'CType', 'USD', 'EU']
. But if I execute df.index.values
I will get [0 1 2 3]
. So, what exactly is the first column and can it be avoided?