OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

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

  • Thread starter Thread starter Migs Panganiban
  • Start date Start date
M

Migs Panganiban

Guest
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:

Code:
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:

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:

Code:
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:

Code:
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):

Code:
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()
<p>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:</p>
<pre><code>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
</code></pre>
<p>I tried using this code:</p>
<pre><code>dataall.groupby('Title')['Rating'].value_counts()
</code></pre>
<p>It did count the ratings for a specific title, however, it didn't show all of the data, basically something like this:</p>
<pre><code>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
</code></pre>
<p>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:</p>
<pre><code>AttributeError: 'DataFrame' object has no attribute 'set_option'
</code></pre>
<p>I also tried viewing the output fullscreen, but it still showed the 3 dots, instead of the full data.</p>
<p>IDK how to make it show all of the data, if you decide to help it's very much appreciated.</p>
<p>BTW here is the full code (spread across different cells):</p>
<pre><code>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()
</code></pre>
 
Top