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

ziggy
  • 1,488
  • 5
  • 23
  • 51
  • Question: why dont you want the index? – anky Aug 02 '19 at 18:40
  • because I am creating a JSON array to display on a webpage and its just screwing it up – ziggy Aug 02 '19 at 18:41
  • are you using `df.to_json()` if so i think you can use `orient=r` : https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.DataFrame.to_json.html – anky Aug 02 '19 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 – ziggy Aug 02 '19 at 18:44

1 Answers1

1
print x.to_string(index=False)

should do the trick

Alexander
  • 88
  • 5