Python Forum
Pandas dataframe without index
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas dataframe without index
Hi guys,

I have a basic question about dataframes. However, my Google search has not yielded the desired results so far. I have data stored in a pandas.core.frame.DataFrame called data_stocks. When I type data_stocks and press CTRL + Enter, a simple DataFrame table is created. This table shows an index column that I would like to get rid of without changing the format of the table (that is, without converting the table to a different format).

Google search results recommended printing the table and using (index=false), however this changes the layout of the table, which is not the intention.

I would be grateful for any help!

Best regards!

Are you just trying to hide the index from display, or do you have a reason to eliminate the index entirely (and why?) If just trying to hide it, make a dataframe from a slice of the original and display that.
tgottsc1 likes this post
I should have tried before posting. Playing with this, I think your best bet is
df.reset_index(drop=True, inplace=True)
Though you still see the row numbers when you display
From script.
In NoteBook.
[Image: KorLwI.png]
More normal to remove index when want save a DataFrame to different format.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Structuring and pivoting corrupted dataframe in pandas gunner1905 2 161 Sep-18-2021, 01:30 PM
Last Post: gunner1905
  TypeError: 'DataFrame' object is not callable using Pandas in Python sofiavlachou 1 172 Sep-02-2021, 03:24 PM
Last Post: buran
  Problem in saving .xlsm (excel) file using pandas dataframe in python shantanu97 2 262 Aug-29-2021, 12:39 PM
Last Post: snippsat
  Partial Matching Rows In Pandas DataFrame Query eddywinch82 1 344 Jul-08-2021, 06:32 PM
Last Post: eddywinch82
  Pandas dictionary dataframe help michaelserra 4 483 Jun-19-2021, 10:26 AM
Last Post: michaelserra
  How to rename dataframe columns based on the content in an index? ar_mahdavi 2 683 Jun-07-2021, 06:09 AM
Last Post: ricslato
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 484 May-04-2021, 10:51 PM
Last Post: rhat398
Star Split and organize my Pandas Dataframe brunolelli 4 752 Apr-18-2021, 03:00 AM
Last Post: brunolelli
  Convert MultiLayer XML to DataFrame using Pandas vsingh17 0 642 Apr-14-2021, 03:50 PM
Last Post: vsingh17
  Pandas DataFrame Code Query eddywinch82 6 1,169 Feb-12-2021, 09:55 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020