\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{CodingJinxx} \pdfinfo{ /Title (codingjinxx-pandas-facts.pdf) /Creator (Cheatography) /Author (CodingJinxx) /Subject (CodingJinxx Pandas Facts Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{35DDF0} \definecolor{LightBackground}{HTML}{E5FAFD} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{CodingJinxx Pandas Facts Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{CodingJinxx} via \textcolor{DarkBackground}{\uline{cheatography.com/140865/cs/30026/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}CodingJinxx \\ \uline{cheatography.com/codingjinxx} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 2nd December, 2021.\\ Updated 9th December, 2021.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Pandas Datastructures}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The primary two components of pandas are the Series and DataFrame.% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dataframes and Series}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/codingjinxx_1638456625_series-and-dataframe.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A Series is One Dimensional Data \newline A Dataframe is N-Dimensional Data} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Creating a Dataframe from Scratch}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{data = \{ \newline 'apples': {[}3, 2, 0, 1{]}, \newline 'oranges': {[}0, 3, 7, 2{]} \newline \} \newline purchases = pd.DataFrame(data)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Turns a Dictionary into a Dataframe} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Adding an Index to a Dataframe}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{purchases = pd.DataFrame(data, index={[}'June', 'Robert', 'Lily', 'David'{]})} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A Dataframe is a (key, value) based Data Structure} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dataframe with Index Set}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/codingjinxx_1638457048_dataspell64_nRn4c912gs.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Understanding your Data}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/codingjinxx_1639061116_dataspell64_38mCRSCweE.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{movies\_df.describe() \newline \newline \# Describing individual columns \newline movies\_df{[}'genre'{]}.describe()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{movies\_df{[}'genre'{]}.value\_counts().head(10)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/codingjinxx_1639061280_dataspell64_ic9cEYKesr.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{movies\_df.corr()}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/codingjinxx_1639061361_dataspell64_0pD1WI2JH5.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Generates a matrix describing correlation between data} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reading in Data}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{It's quite simple to load data from various file formats into a DataFrame. In the following examples we'll keep using our apples and oranges data, but this time it's coming from various files.% Row Count 4 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reading CSV}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{df = \seqsplit{pd.read\_csv('purchases.csv')} \newline \newline \# Or with setting the index column, needs to be set with CSV \newline \newline df = \seqsplit{pd.read\_csv('purchases.csv'}, index\_col=0)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reading JSON}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# The index is automatically set with json \newline df = \seqsplit{pd.read\_json('purchases.json')}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Reading in SQLite}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import sqlite3 \newline con = \seqsplit{sqlite3.connect("database.db")} \newline df = \seqsplit{pd.read\_sql\_query("SELECT} * FROM purchases", con)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Setting index in post}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{df = df.set\_index('index')} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Writing Data}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{df.to\_csv('new\_purchases.csv')} \newline df.to\_json('new\_purchases.json') \newline df.to\_sql('new\_purchases', con)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{con being a sql connection \newline \newline When we save JSON and CSV files, all we have to input into those functions is our desired filename with the appropriate file extension. With SQL, we're not creating a new file but instead inserting a new table into the database using our con variable from before.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dataframe Slicing Extracting Selecting}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Up until now we've focused on some basic summaries of our data. We've learned about simple column extraction using single brackets, and we imputed null values in a column using fillna(). Below are the other methods of slicing, selecting, and extracting you'll need to use constantly. \newline % Row Count 6 (+ 6) It's important to note that, although many methods are the same, DataFrames and Series have different attributes, so you'll need be sure to know which type you are working with or else you will receive attribute errors. \newline % Row Count 11 (+ 5) Let's look at working with columns first.% Row Count 12 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{By Columns}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{genre\_col = movies\_df{[}'genre'{]} \newline genre\_col = movies\_df{[}{[}'genre'{]}{]} \newline subset = movies\_df{[}{[}'genre', 'rating'{]}{]} \newline subset.head()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{To extract data as Dataframes from a dataframe pass a list key} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{By Rows}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{prom = movies\_df.loc{[}"Prometheus"{]} \newline prom = movies\_df.iloc{[}1{]} \newline \newline \newline movie\_subset = movies\_df.loc{[}'Prometheus':'Sing'{]} \newline movie\_subset = movies\_df.iloc{[}1:4{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{loc and iloc can be thought of as similar to Python list slicing. To show this even further, let's select multiple rows.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Conditional Selections}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{condition = (movies\_df{[}'director'{]} == "Ridley Scott") \newline \newline movies\_df{[}movies\_df{[}'director'{]} == "Ridley Scott"{]}.head() \# Returns a Dataframe where Director is Ridley Scott \newline \newline movies\_df{[}movies\_df{[}'rating'{]} \textgreater{}= 8.6{]}.head(3) \newline \newline \newline movies\_df{[}(movies\_df{[}'director'{]} == 'Christopher Nolan') | (movies\_df{[}'director'{]} == 'Ridley Scott'){]}.head() \newline \newline \# OR Simply \newline \newline movies\_df{[}movies\_df{[}'director'{]}.isin({[}'Christopher Nolan', 'Ridley Scott'{]}){]}.head() \newline \newline movies\_df{[} \newline ((movies\_df{[}'year'{]} \textgreater{}= 2005) \& (movies\_df{[}'year'{]} \textless{}= 2010)) \newline \& (movies\_df{[}'rating'{]} \textgreater{} 8.0) \newline \& (movies\_df{[}'revenue\_millions'{]} \textless{} movies\_df{[}'revenue\_millions'{]}.quantile(0.25)) \newline {]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Similar to isnull(), this returns a Series of True and False values: True for films directed by Ridley Scott and False for ones not directed by him.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Applying Functions to Data}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def rating\_function(x): \newline if x \textgreater{}= 8.0: \newline return "good" \newline else: \newline return "bad" \newline \newline movies\_df{[}"rating\_category"{]} = movies\_df{[}"rating"{]}.apply(rating\_function)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Viewing Data}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{movies\_df.head() \# Print first 5 rows \newline movies\_df.head(10) \# Print first 10 rows \newline \newline movies\_df.tail() \# Print last 5 Rows \newline movies\_df.tail(2) \# Print last 2 rows} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Previews start or ends of dataframes} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Getting metadata from a dataframe}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{movies\_df.info() \# Output info regarding datatypes \newline movies\_df.shape \# Outputs number of rows and columns} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Dataframe Info}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/codingjinxx_1638458337_dataspell64_NjFqlQ1Aw6.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{df.info()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Cleaning Data}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\#\#\# Duplicate Data Handling \newline temp\_df = \seqsplit{temp\_df.drop\_duplicates()} \# Drops duplicate data \newline \# Or \newline temp\_df.drop\_duplicates(inplace=True) \newline \# Keeping duplicate data \newline temp\_df.drop\_duplicates(inplace=True, keep=True) \newline \newline \#\#\# Renaming Columns \newline movies\_df.rename(columns=\{ \newline 'Runtime (Minutes)': 'Runtime', \newline 'Revenue (Millions)': 'Revenue\_millions' \newline \}, inplace=True) \newline \# Can also be set directly \newline movies\_df.columns = {[}'rank', 'genre', 'description', 'director', 'actors', 'year', 'runtime', \newline 'rating', 'votes', 'revenue\_millions', 'metascore'{]} \newline \# Setting column names lowercase \newline movies\_df.columns = {[}col.lower() for col in movies\_df{]} \newline \newline \#\#\# Handling Null Values \newline movies\_df.isnull() \# Returns a column with either True or False for null or not \newline movies\_df.isnull().sum() \# Returns a count of all null entries \newline \# Removing Nulls \newline movies\_df.dropna() \newline \# Specify the axis to drop against \newline movies\_df.dropna(axis=1)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Plotting with Matplotlib}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Another great thing about pandas is that it integrates with Matplotlib, so you get the ability to plot directly off DataFrames and Series. To get started we need to import Matplotlib (pip install matplotlib):% Row Count 5 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Scatter plot}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import matplotlib.pyplot as plt \newline plt.rcParams.update(\{'font.size': 20, 'figure.figsize': (10, 8)\}) \# set font and plot size to be larger \newline \newline movies\_df.plot(kind='scatter', x='rating', y='revenue\_millions', title='Revenue (millions) vs Rating');} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Histogram plot}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{movies\_df{[}'rating'{]}.plot(kind='hist', title='Rating');} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Boxplot}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{movies\_df{[}'rating'{]}.plot(kind="box");} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Boxplot}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Image could not be loaded.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}