Search code examples
pythonpython-3.xdataframegoogle-colaboratory

How to show all of the data instead of the first 5 and the last 5 rows


What I want to do is show all of the data and use value_counts() to count the amount of a specific rating (in this case 1) for a specific Title. Basically something like this:

Title                   Rating
$1,000,000 Duck (1971)  3          15
                        2           8
                        4           7
                        5           4
                        1           3 
eXistenZ (1999)         4         142
                        3         109
                        2          61
                        5          55
                        1          43
Sliding Doors (1998)    4         211
                        3         121
                        5         115
                        2          32
                        1          11

I tried using this code:

dataall.groupby('Title')['Rating'].value_counts()

It did count the ratings for a specific title, however, it didn't show all of the data, basically something like this:

Title                   Rating
$1,000,000 Duck (1971)  3          15
                        2           8
                        4           7
                        5           4
                        1           3
                                 ... 
eXistenZ (1999)         4         142
                        3         109
                        2          61
                        5          55
                        1          43

So I went to look for how to show all of the data, and tried using set_option('max_rows', None), but it just gave this error:

AttributeError: 'DataFrame' object has no attribute 'set_option'

I also tried viewing the output fullscreen, but it still showed the 3 dots, instead of the full data.

IDK how to make it show all of the data, if you decide to help it's very much appreciated.

BTW here is the full code (spread across different cells):

from google.colab import drive
drive.mount('/content/drive')

from pandas import *
from matplotlib.pyplot import *
from math import *

import numpy as num
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib inline

import seaborn as sns

import statistics

movies = pd.read_table("/content/drive/MyDrive/Colab Notebooks/Datasets/movies.dat",sep="::",names=['MovieID','Title','Genres'],encoding='latin-1')
ratings = pd.read_table("/content/drive/MyDrive/Colab Notebooks/Datasets/ratings.dat",sep="::",names=['UserID','MovieID','Rating','Time'],encoding='latin-1')
users = pd.read_table("/content/drive/MyDrive/Colab Notebooks/Datasets/users1.dat",sep="::",names=['UserID','Gender','Age','Occupation','ZipCode'],encoding='latin-1')

allData = pd.merge(pd.merge(movies, ratings, on="MovieID"), users, on="UserID")
dataall = allData[allData.columns[1:11]]
dataall.groupby('Title')['Rating'].value_counts()

Solution

  • Use this code without assigning it to anything. It is a global pandas option.

    pd.set_option("display.max_rows", None)
    

    I usually put it in the first code cell of my jupyter notebook together with all the library imports.