04 Stem-and-leaf plots#

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objects as go
import stemgraphic
import findspark; findspark.init()
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
from pyspark.sql import functions as F
spark = SparkSession.builder.appName('statistics').master('local').getOrCreate()
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/home/runner/work/statistics/spark-3.1.3-bin-hadoop3.2/jars/spark-unsafe_2.12-3.1.3.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
22/07/21 02:34:13 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).

Stem-and-leaf plots fig 1

dataset = [0, 0, 2, 4, 7, 7, 9, 11, 11, 13, 18, 20]
stems = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2]
plt.stem(stems, dataset)
plt.xlabel('Data')
plt.ylabel('Stems')
plt.show()
../_images/04 Stem-and-leaf plots_5_0.png
stemgraphic.stem_graphic(dataset)
(<Figure size 540x144 with 1 Axes>, <Axes:>)
../_images/04 Stem-and-leaf plots_6_1.png