简体   繁体   中英

Data not showing in table form when using Jupyter Notebook

I ran the below code in Jupyter Notebook, I was expecting the output to appear like an excel table but instead the output was split up and not in a table. How can I get it to show up in table format?

import pandas as pd
from matplotlib import pyplot as plt

df = pd.read_csv("Robbery_2014_to_2019.csv")

print(df.head())

Output:

           X          Y  Index_ event_unique_id            occurrencedate  \
0 -79.270393  43.807190   17430   GO-2015134200  2015-01-23T14:52:00.000Z   
1 -79.488281  43.764091   19205  GO-20142956833  2014-09-21T23:30:00.000Z   
2 -79.215836  43.761856   15831   GO-2015928336  2015-03-23T11:30:00.000Z   
3 -79.436264  43.642963   16727  GO-20142711563  2014-08-15T22:00:00.000Z   
4 -79.369461  43.654526   20091  GO-20142492469  2014-07-12T19:00:00.000Z   

               reporteddate premisetype  ucr_code  ucr_ext  \
0  2015-01-23T14:57:00.000Z     Outside      1610      210   
1  2014-09-21T23:37:00.000Z     Outside      1610      200   
2  2015-06-03T15:08:00.000Z       Other      1610      220   
3  2014-08-16T00:09:00.000Z   Apartment      1610      200   
4  2014-07-14T01:35:00.000Z   Apartment      1610      100   

               offence  ...  occurrencedayofyear occurrencedayofweek  \
0   Robbery - Business  ...                 23.0          Friday       
1    Robbery - Mugging  ...                264.0          Sunday       
2      Robbery - Other  ...                 82.0          Monday       
3    Robbery - Mugging  ...                227.0          Friday       
4  Robbery With Weapon  ...                193.0          Saturday     

   occurrencehour      MCI Division  Hood_ID                 Neighbourhood  \
0              14  Robbery      D42      129         Agincourt North (129)   
1              23  Robbery      D31       27  York University Heights (27)   
2              11  Robbery      D43      137                  Woburn (137)   
3              22  Robbery      D11       86             Roncesvalles (86)   
4              19  Robbery      D51       73                Moss Park (73)   

        Long        Lat  ObjectId  
0 -79.270393  43.807190      2001  
1 -79.488281  43.764091      2002  
2 -79.215836  43.761856      2003  
3 -79.436264  43.642963      2004  
4 -79.369461  43.654526      2005  

[5 rows x 29 columns]

Use display(df.head()) (produces slightly nicer output than without display()

Print function is applied to represent any kind of information like string or estimated value. Whereas Display() will display the dataset in

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM