0

very simple question

I am reading an excel sheet with python and I want to print the results without the automatic index pandas adds

import pandas as pd

x=pd.read_excel(r'2_56_01.276295.xlsx',index_col=None)
print x[:3]

this prints the 1st 3 rows

   blahblah           Street Borough
0        55         W 192 ST   Bronx
1      2514  EAST TREMONT AV   Bronx
2       877     INTERVALE AV   Bronx

but I do not want the index

4
  • Question: why dont you want the index? Commented Aug 2, 2019 at 18:40
  • because I am creating a JSON array to display on a webpage and its just screwing it up Commented Aug 2, 2019 at 18:41
  • are you using df.to_json() if so i think you can use orient=r : pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/… Commented Aug 2, 2019 at 18:43
  • 1
    @anky_91 did not know about this, looks super useful but the JSON is parsed in a unique way. but this may be of help Commented Aug 2, 2019 at 18:44

1 Answer 1

1
print x.to_string(index=False)

should do the trick

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.