3

here is my dataframe

enter image description here

my csv file is

date,open,high,low,close,volume,cap,Unnamed: 7
20190816,28600,28850,28150,28350,335508,6065213000000,
20190814,29550,29600,28800,28950,296026,6193563000000,
20190813,29400,29900,29400,29550,196955,6321927000000,
20190812,29450,30350,29400,29850,166580,6386109000000,
20190809,29500,30300,29450,29750,468338,6364715000000,
20190808,29000,30000,29000,29650,448959,6343321000000,
20190807,29800,29800,28950,29000,431524,6204260000000,
20190806,30900,30950,29650,29900,710348,6396806000000,
20190805,30300,31100,30300,30950,608970,6621443000000,
20190802,30400,30750,29900,30400,420984,6503776000000,

I don't know why 0 ~ 11 index exists

I want to remove this (0~11)

I searched and tried index_col=False, index_col=None and to_csv with index=False but The problem was not resolved.

how can I remove this index(0~11)?

Your valuable opinions and thoughts will be very much appreciated.

GoBackess
  • 404
  • 3
  • 17

3 Answers3

1

The only solution that fully matches what you desire is to create a string:

print(df.to_string(index=False))

Another solution would be the below, it will still be a dataframe, but just the first column's values will be shifted down one level:

print(df.set_index('date'))
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
1

You cannot remove the index of a Pandas DataFrame. It is not one of the columns of your DataFrame. And it is not coming from the csv file.

See: https://stackoverflow.com/a/20107825/4936825

Milad Shahidi
  • 627
  • 7
  • 13
1

You can not display this automatically generated index with „df.style.hide_index()“ or set one of the colums as index with set_index() method.

moys
  • 7,747
  • 2
  • 11
  • 42