<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
data = [2,1,0,2,1,3,0,2,4,0,3,2,3,4,2,2,2,4,3,0]
frek = pd.Series(data).value_counts().reset_index().sort_values('index').reset_index(drop='True')
frek.columns = ['nilai rentang', 'frekuensi']
print(frek)

#=======histogram===========
plt.hist(data, bins=30)
plt.ylabel('frekuensi')
plt.show()
taskdata = [84,86,89,92,82,86,89,92,80,86,87,90]
jumlah  = pd.Series(taskdata).sum()
print(jumlah)
#scatter diagram
#create data
N=200
g1 = (0.6 + 0.6 * np.random.rand(N), np.random.rand(N))
g2 = (0.4 + 0.3 * np.random.rand(N), 0.5 * np.random.rand(N))
g3 = (0.3 * np.random.rand(N), 0.3 * np.random.rand(N))
x,y = g1
print (x,y)

data = (g1, g2, g3)
colors = ("red", "green", "blue")
groups = ("coffee", "tea", "water")

#create plot
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

for data, color, group in zip (data, colors, groups):
  x,y = data
  ax.scatter(x,y,alpha=0.8, c=color, edgecolors='none', s=30, label=group)
  
plt.title('matplot scatter data')
plt.legend(loc=2)
plt.show()
#using another data
df_cars = pd.read_csv("https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv")
print(df_cars)
df_cars.mean()<jupyter_output>model   mpg  cyl   disp   hp  ...   qsec  vs  am  gear  carb
0             Mazda RX4  21.0    6  160.0  110  ...  16.46   0   1     4     4
1         Mazda RX4 Wag  21.0    6  160.0  110  ...  17.02   0   1     4     4
2            Datsun 710  22.8    4  108.0   93  ...  18.61   1   1     4     1
3        Hornet 4 Drive  21.4    6  258.0  110  ...  19.44   1   0     3     1
4     Hornet Sportabout  18.7    8  360.0  175  ...  17.02   0   0     3     2
5               Valiant  18.1    6  225.0  105  ...  20.22   1   0     3     1
6            Duster 360  14.3    8  360.0  245  ...  15.84   0   0     3     4
7             Merc 240D  24.4    4  146.7   62  ...  20.00   1   0     4     2
8              Merc 230  22.8    4  140.8   95  ...  22.90   1   0     4     2
9              Merc 280  19.2    6  167.6  123  ...  18.30   1   0     4     4
10            Merc 280C  17.8    6  167.6  123  ...  18.90   1   0     4     4
11           Merc 450SE  16.4    8  275.8  180  ... [...]
{'fraction_non_alphanumeric': 0.15404699738903394, 'fraction_numerical': 0.15926892950391644, 'mean_word_length': 1.8845671267252195, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '167328', 'license': 'MIT', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1011, 'n_words': 251, 'path': 'SortingWithPython-master/sorting.ipynb', 'repo_name': 'phanatagama/Data-Science', 'size': '2298'}