0

I'm not getting my whole output as well as my column names in my Screen.

import sqlite3
import pandas as pd
hello = sqlite3.connect(r"C:\Users\ravjo\Downloads\Chinook.sqlite")
rs = hello.execute("SELECT * FROM PlaylistTrack INNER JOIN Track on PlaylistTrack.TrackId = Track.TrackId WHERE Milliseconds < 250000")
df = pd.DataFrame(rs.fetchall())
hello.close()
print(df.head())

actual result:

    0     1     2                 3    4   ...   6     7       8        9     10
0   1  3390  3390  One and the Same  271  ...   23  None  217732  3559040  0.99
1   1  3392  3392     Until We Fall  271  ...   23  None  230758  3766605  0.99
2   1  3393  3393     Original Fire  271  ...   23  None  218916  3577821  0.99
3   1  3394  3394       Broken City  271  ...   23  None  228366  3728955  0.99
4   1  3395  3395          Somedays  271  ...   23  None  213831  3497176  0.99

[5 rows x 11 columns]

expected result:

   PlaylistId  TrackId  TrackId              Name  AlbumId  MediaTypeId  \
0           1     3390     3390  One and the Same      271            2   
1           1     3392     3392     Until We Fall      271            2   
2           1     3393     3393     Original Fire      271            2   
3           1     3394     3394       Broken City      271            2   
4           1     3395     3395          Somedays      271            2   

   GenreId Composer  Milliseconds    Bytes  UnitPrice  
0       23     None        217732  3559040       0.99  
1       23     None        230758  3766605       0.99  
2       23     None        218916  3577821       0.99  
3       23     None        228366  3728955       0.99  
4       23     None        213831  3497176       0.99
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
  • Possible duplicate of [Pandas: Setting no. of max rows](https://stackoverflow.com/questions/16424493/pandas-setting-no-of-max-rows) – Hardik Sondagar Oct 27 '19 at 08:47

3 Answers3

1

The ... in the middle actually says that some of the data have been omitted from display. If you want to see the entire data, you should modify the pandas options. You can do so by using pandas.set_option() method. Documentation here.

In your case, you should set display.max_columns to None so that pandas displays unlimited number of columns. You will have to read in the column names from the database of set it manually. Refer here on how to read in the column names from the database itself.

najeem
  • 1,841
  • 13
  • 29
0

To display all the columns please use below mentioned code snippet. pd.set_option("display.max_columns",None)

DavidW
  • 29,336
  • 6
  • 55
  • 86
0

By default, pandas limits number of rows for display. However you can change it to as per your need. Here is helper function I use, whenever I need to print full data-frame

def print_full(df):
    import pandas as pd
    pd.set_option('display.max_rows', len(df))
    print(df)
    pd.reset_option('display.max_rows')
Hardik Sondagar
  • 4,347
  • 3
  • 28
  • 48