751 - 800 Flashcards

1
Q

maths.Standard Deviation

A

is a measure of how spread out numbers are. Its symbol is σ (the greek letter sigma). it is the square root of the Variance.

Example: (600, 470, 170, 430, 300)

1) Mean: (600 + 470 + 170 + 430 + 300) / 5 = 394

2) Difference from Mean: (600 - 394, 470 - 394, 170 - 394, 430 - 394, 300 - 394) 
(206, 76, -224, 36, -94)

3) Variance = (206^2 + 76^2 + (-224^2) + 36^2 + (-94^2)) / 5 = 21704

4) Standard Deviation: √21704 = 147,32
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

maths.Normal distribution

A

is an arrangement of a data set in which most values cluster in the middle of the range and the rest taper off symmetrically toward either extreme.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

maths.Statistical Distribution or maths.Probability Distribution

A

is the mathematical function that gives the probabilities of occurrence of different possible outcomes for an experiment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

string.removesuffix(suffix, /)

🎯 suffix - строка-суффикс, который необходимо удалить.

A

заканчивается строкой суффикса suffix, то метод возвращает копию строки без суффикса. Если суффикс suffix в исходной строке str не обнаружен, то метод возвращает копию исходной строки str.

line = 'TmpDirMixin'

print(line.removesuffix('Tests'))
👉 TmpDirMixin

print(line.removesuffix('x'))
👉 TmpDirMixin

print(line.removesuffix('xin'))
👉 TmpDirMi
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

maths.Line Graph

A

a graph that shows information connected in some way (usually as it changes over time).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

maths.Scatter Plot

A

graph of plotted points showing the relationship between two data sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

maths.Bar Graph and maths.Bar Chart

A

graphical display of data using bars of different heights. It is a really good way to show relative sizes . Bar Graphs are good when your data is in categories

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

heapq.heappush(heap, item)

🎯 heap - список с кучей,
🎯 item - добавляемый элемент

Кучи - это двоичные деревья, для которых каждый родительский узел имеет значение, меньшее или равное любому из его дочерних элементов. Интересным свойством кучи является то, что ее наименьшим элементом всегда является корень heap[0].

A

добавляет значение элемента item в кучу heap, сохраняя инвариант кучи и сортирует от меньшего к болшьшему.

from heapq import heappush

h = []
heappush(h, (5, 'write code'))
heappush(h, (7, 'release product'))
heappush(h, (1, 'write spec'))
heappush(h, (3, 'create tests'))
print(h)

👉 [(1, 'write spec'), (3, 'create tests'), (5, 'write code'), (7, 'release product')]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

heapq.nlargest and nsmallest(n, iterable, key=None)

🎯 key — определяет функцию с одним аргументом, которая используется для извлечения ключа
сравнения из каждого элемента в итерируемой последовательности iterable, например key=str.lower.

A

возвращает список с n самыми большими или наименьшими элементами из набора данных, определенного с помощью итерируемой последовательности iterable.

import heapq
seq = [100, 2, 400, 500, 400]

heapq.nsmallest(2, seq)
👉 [2, 100]
seq = [100, 2, 400, 500, 400]
heapq.nsmallest(2, enumerate(seq), key=lambda x: x[1])

👉 [(1, 2), (0, 100)]
seq = [100, 2, 400, 500, 400]
heapq.nlargest(2, seq)

👉 [500, 400]
seq = [100, 2, 400, 500, 400]
heapq.nlargest(2, enumerate(seq), key=lambda x: x[1])

👉 [(3, 500), (2, 400)]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

heapq.merge(*iterables, key=None, reverse=False)

A

объединяет несколько отсортированных последовательностей *iterables в один отсортированный итератор.

first_list = sorted([45, 12, 63, 95])
second_list = sorted([42, 13, 69, 54, 15])
final_list = list(heapq.merge(first_list, second_list))

👉 [12, 13, 15, 42, 45, 54, 63, 69, 95]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

heapq.heapify(x)

🎯 x - список элементов.

A

преобразовывает список x в кучу на месте за линейное время.

import heapq
h = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]
heapq.heapify(h)
print(h)

👉 [0, 1, 2, 6, 3, 5, 4, 7, 8, 9]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

heapq.heapreplace(heap, item)

🎯 heap - список с кучей,
🎯 item - добавляемый элемент.

A

сначала удаляет и возвращает наименьший элемент из кучи heap, а потом добавляет новый элемент item. Размер кучи heap не меняется.

h = [(3, 'three'), (1, 'one'), (7, 'seven'), (5, 'five'), (9, 'nine')]
heapq.heapify(h)

heapq.heapreplace(h, (0, 'zero'))
print(h)
👉 [(0, 'zero'), (3, 'three'), (7, 'seven'), (5, 'five'), (9, 'nine')]

heapq.heapreplace(h, (222, 'zero'))
print(h)
👉 [(3, 'three'), (5, 'five'), (7, 'seven'), (222, 'zero'), (9, 'nine')]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

heapq.heappushpop(heap, item)

🎯 heap - список с кучей,
🎯 item - добавляемый элемент.

A

добавляет значение элемента item в кучу heap, затем возвращает и удаляет самый маленький элемент из кучи heap.

h = [(3, 'three'), (1, 'one'), (7, 'seven'), (5, 'five'), (9, 'nine')]
heapq.heapify(h)

heapq.heappushpop(h, (10, 'zero'))
print(h)
👉 [(3, 'three'), (5, 'five'), (7, 'seven'), (10, 'zero'), (9, 'nine')]

heapq.heappushpop(h, (1, 'zero'))
print(h)
👉 [(3, 'three'), (5, 'five'), (7, 'seven'), (10, 'zero'), (9, 'nine')]

heapq.heappushpop(h, (3, 'ttttttttttttttttttt'))
print(h)
👉 [(3, 'ttttttttttttttttttt'), (5, 'five'), (7, 'seven'), (10, 'zero'), (9, 'nine')]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

heapq.heappop(heap)

A

возвращает и удаляет наименьший элемент из кучи heap, сохраняя инвариант кучи.

h = [(3, 'three'), (1, 'one'), (7, 'seven'), (5, 'five'), (9, 'nine')]
heapq.heapify(h)

heapq.heappop(h)
print(h)
👉 [(3, 'three'), (5, 'five'), (7, 'seven'), (9, 'nine')]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

string.capwords(s, sep=None)

🎯 s - произвольная строка.
🎯 sep=None - строка, используется для разделения и объединения слов.

A

разделяет строку s на слова с помощью метода str.split(), далее используя метод строки str.capitalize() преобразует каждое слово с заглавной буквы и соединяет полученные слова используя метод str.join().

s = 'The quick brown fox jumped over the lazy dog.'

print(string.capwords(s))
👉 The Quick Brown Fox Jumped Over The Lazy Dog.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

string.removeprefix(prefix, /)

🎯 prefix - строка-префикс, который необходимо удалить.

A

возвращает копию строки без префикса. Если префикс prefix в исходной строке str не обнаружен, то метод возвращает копию исходной строки str.

line = 'BaseTestCase'
print(line.removeprefix('Test'))
👉 BaseTestCase

print(line.removeprefix('a'))
👉 BaseTestCase

print(line.removeprefix('Base'))
👉 TestCase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

maths.Histogram

🎯 weight
🎯 height
🎯 how much time

A

a graphical display of data using bars of different heights. It is similar to a Bar Chart, but a histogram groups numbers into ranges. The height of each bar shows how many fall into each range. And you decide what ranges to use!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

eval(expression, globals=None, locals=None)

🎯 expression - строка-выражение, которую требуется исполнить. Либо объект кода, что возвращает compile()
🎯 globals=None - словарь глобального пространства, относительно которого следует исполнить выражение
🎯 locals=None - переменные локального пространства, в котором следует исполнить выражение.

A

выполняет строку-выражение, переданную ей в качестве обязательного аргумента и возвращает результат выполнения этой строки.

x = "print('Привет')"
eval(x)
👉 Привет
y = 'print("5 + 10 =", (5+10))'
eval(y)
👉 5 + 10 = 15
s=3
eval('s==3')
👉 True
s=3
eval('s + 1')
👉 4
s=3
eval('s')
👉 3
s=3
eval('str(s)+"test"')
👉 '3test'
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

maths.Correlation(corr(X,Y) or ρX,Y)

A

When two sets of data are strongly linked together we say they have a High Correlation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

maths.Central Value

A

with just 2 numbers the answer is easy: go half-way between.

Example: what is the central value for 3 and 7?
Answer: Half-way between, which is 5.

We can calculate it by adding 3 and 7 and then dividing the result by 2: (3+7) / 2 = 5
Example: what is the central value of 3, 7 and 8?

Answer: We calculate it by adding 3, 7 and 8 and then dividing the results by 3 
(because there are 3 numbers): (3+7+8) / 3 = 18/3 = 6
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

maths.Median(x̄)

A

is the “middle” of a sorted list of numbers. With an even amount of numbers things are slightly different. In that case we find the middle pair of numbers, and then adding them together and dividing by two.

A quick way to find the middle: Count how many numbers, add 1, then divide by 2

Median of (12, 3, 5)
Put them in order: 3, 5, 12

👉 The middle is 5, so the median is 5.
Example: (3, 13, 7, 5, 21, 23, 39, 23, 40, 23, 14, 12, 56, 23, 29)
When we put those numbers in order we have: 3, 5, 7, 12, 13, 14, 21, 23, 23, 23, 23, 29, 39, 40, 56

👉 The median value of this set of numbers is 23.
Example: (3, 13, 7, 5, 21, 23, 23, 40, 23, 14, 12, 56, 23, 29)

When we put those numbers in order we have: 3, 5, 7, 12, 13, 14, 21, 23, 23, 23, 23, 29, 40, 56

👉 To find the value halfway between them, add them together and divide by 2:
21 + 23 = 44 then 44 ÷ 2 = 22
22
Q

maths.Mode(Mo)

A

is simply the number which appears most often.

In {6, 3, 9, 6, 6, 5, 9, 3} the Mode is 6, as it occurs most often.
23
Q

maths.Harmonic Mean

A

the reciprocal of the average of the reciprocals

Harmonic mean of (1, 2, 4)?

The reciprocals of 1, 2 and 4 are: (1/1) = 1, (1/2) = 0.5, (1/4) = 0.25

Now add them up: 1 + 0,5 + 0,25 = 1,75

Average: 1,75 / 3

The reciprocal of that average: 3 / 1,75 = 1,714
24
Q

maths.mean | maths.arithmetic mean | maths.average

A

просто среднеарифметическое.

6, 11, 7
Add the numbers: 6 + 11 + 7 = 24
Divide by how many numbers (there are 3 numbers): 24 / 3 = 8
The Mean is 8
3, −7, 5, 13, −2
The sum of these numbers is 3 − 7 + 5 + 13 − 2 = 12
There are 5 numbers.
The mean is equal to 12 ÷ 5 = 2,4
The mean of the above numbers is 2,4

Here is how to do it one line: Mean = (3 − 7 + 5 + 13 − 2) / 5 = 12 / 5 = 2,4
25
Q

numpy.nditer(op, flags=None, op_flags=None, op_dtypes=None, order=’K’, casting=’safe’, op_axes=None, itershape=None, buffersize=0)

A

Efficient multi-dimensional iterator object to iterate over arrays. To get started using this object, see the introductory guide to array iteration.

a = geek.arange(12)
# shape array with 3 rows and 
# 4 columns
a = a.reshape(3,4)
 
print('Original array is:')
print(a)
print()
print('Modified array is:')

for x in geek.nditer(a):
    print(x)

Original array is:
[[ 0 1 2 3]
 [ 4 5 6 7]
 [ 8 9 10 11]]

Modified array is:
0 1 2 3 4 5 6 7 8 9 10 11
a = geek.arange(12)
# shape array with 3 rows and 
# 4 columns 
a = a.reshape(3,4)
print('Original array is:')
print(a)
print()
# modifying array values
for x in geek.nditer(a, op_flags = ['readwrite']):
    x[...] = 5*x
print('Modified array is:')
print(a)

Original array is:
[[ 0 1 2 3]
 [ 4 5 6 7]
 [ 8 9 10 11]]

Modified array is:
[[ 0 5 10 15]
 [20 25 30 35]
 [40 45 50 55]]
26
Q

seaborn.set_style(style=None, rc=None)

A

Set the parameters that control the general style of the plots. The style parameters control properties like the color of the background and whether a grid is enabled by default.

sns.set_style("whitegrid")
sns.barplot(x=["A", "B", "C"], y=[1, 3, 2])
sns.set_style("darkgrid", {"grid.color": ".6", "grid.linestyle": ":"})
sns.lineplot(x=["A", "B", "C"], y=[1, 3, 2])
# load the tips dataset present by default in seaborn
tips = sns.load_dataset('tips')
sns.set_style('white')

make a countplot
sns.countplot(x ='sex', data = tips)
tips = sns.load_dataset('tips')
sns.lmplot(x ='total_bill', y ='tip', size = 2, aspect = 4, data = tips)
27
Q

seaborn.set_context(context=None, font_scale=1, rc=None)

A

Set the parameters that control the scaling of plot elements. This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style.

sns.set_context("notebook")
sns.lineplot(x=[0, 1, 2], y=[1, 3, 2])
sns.set_context("notebook", font_scale=1.25)
sns.lineplot(x=[0, 1, 2], y=[1, 3, 2])
sns.set_context("notebook", rc={"lines.linewidth": 3})
sns.lineplot(x=[0, 1, 2], y=[1, 3, 2])
28
Q

seaborn.despine(fig=None, ax=None, top=True, right=True, left=False, bottom=False, offset=None, trim=False)

A

Remove the top and right spines from plot(s).

29
Q

seaborn.PairGrid(**kwargs)

A

Subplot grid for plotting pairwise relationships in a dataset.This object maps each variable in a dataset onto a column and row in a grid of multiple axes.

penguins = sns.load_dataset("penguins")
g = sns.PairGrid(penguins)
g = sns.PairGrid(penguins)
g.map(sns.scatterplot)
g = sns.PairGrid(penguins)
g.map_diag(sns.histplot)
g.map_offdiag(sns.scatterplot)
df = seaborn.load_dataset('tips')
# PairGrid object with hue
graph = seaborn.PairGrid(df, hue ='day')
# type of graph for diagonal
graph = graph.map_diag(plt.hist)
# type of graph for non-diagonal
graph = graph.map_offdiag(plt.scatter)
# to add legends
graph = graph.add_legend()
# to show
plt.show()
30
Q

seaborn.swarmplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor=’gray’, linewidth=0, ax=None, **kwargs)

A

Draw a categorical scatterplot with non-overlapping points.

sns.set_theme(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.swarmplot(x=tips["total_bill"])
ax = sns.swarmplot(x="day", y="total_bill", data=tips)
ax = sns.swarmplot(x="day", y="total_bill", hue="sex", data=tips)
seaborn.set(style='whitegrid')
fmri = seaborn.load_dataset("fmri")
seaborn.swarmplot(x="timepoint", y="signal", data=fmri)
seaborn.set(style='whitegrid')
fmri = seaborn.load_dataset("fmri")
seaborn.swarmplot(x="timepoint", y="signal", hue="region", data=fmri)
31
Q

seaborn.clustermap(data, *, pivot_kws=None, method=’average’, metric=’euclidean’, z_score=None, standard_scale=None, figsize=(10, 10), cbar_kws=None, row_cluster=True, col_cluster=True, row_linkage=None, col_linkage=None, row_colors=None, col_colors=None, mask=None, dendrogram_ratio=0.2, colors_ratio=0.03, cbar_pos=(0.02, 0.8, 0.05, 0.18), tree_kws=None, **kwargs)

A

Plot a matrix dataset as a hierarchically-clustered heatmap.

iris = sns.load_dataset("iris")
species = iris.pop("species")
g = sns.clustermap(iris)
g = sns.clustermap(iris, figsize=(7, 5), row_cluster=False, dendrogram_ratio=(.1, .2), cbar_pos=(0, .2, .03, .4))
lut = dict(zip(species.unique(), "rbg"))
row_colors = species.map(lut)
g = sns.clustermap(iris, row_colo
rs=row_colors)
data = sns.load_dataset('flights')
# Categorical encoding
frequency_encoding(data, 'month')
# Clustering data row-wise and
# changing color of the map.
sns.clustermap(data, figsize=(7, 7)
32
Q

seaborn.FaceGrid()

A

Multi-plot grid for plotting conditional relationships.

df = seaborn.load_dataset('tips')
# Form a facetgrid using columns with a hue
graph = seaborn.FacetGrid(df, col ="sex",  hue ="day")
# map the above form facetgrid with some attributes
graph.map(plt.scatter, "total_bill", "tip", edgecolor ="w").add_legend()
# show the object
plt.show()
df = seaborn.load_dataset('tips')
# Form a facetgrid using columns with a hue
graph = seaborn.FacetGrid(df, row ='smoker', col ='time')
# map the above form facetgrid with some attributes
graph.map(plt.hist, 'total_bill', bins = 15, color ='orange')
# show the object
plt.show()
df = seaborn.load_dataset('tips')
# Form a facetgrid using columns with a hue
graph = seaborn.FacetGrid(df, col ='time', hue ='smoker')
# map the above form facetgrid with some attributes
graph.map(seaborn.regplot, "total_bill", "tip").add_legend()
# show the object
plt.show()
33
Q

numpy.random.seed()

A

используется для установки начального числа для алгоритма генератора псевдослучайных чисел в Python. Идея заключается в том, что мы всегда будем получать один и тот же набор случайных чисел для одного и того же начального числа на любой машине.

import numpy as np
np.random.seed(1)
array = np.random.rand(5)
np.random.seed(1)
array2 = np.random.rand(5)
print(array)
print(array2)

[4.17022005e-01 7.20324493e-01 1.14374817e-04 3.02332573e-01 1.46755891e-01]
[4.17022005e-01 7.20324493e-01 1.14374817e-04 3.02332573e-01 1.46755891e-01]
34
Q

seaborn.violinplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, bw=’scott’, cut=2, scale=’area’, scale_hue=True, gridsize=100, width=0.8, inner=’box’, split=False, dodge=True, orient=None, linewidth=None, color=None, palette=None, saturation=0.75, ax=None, **kwargs)

A

similar activity box plot do. As it shows several quantitative data across one or more categorical variables. It can be an effective and attractive way to show multiple data at several units.

sns.set_theme(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(x=tips["total_bill"])
ax = sns.violinplot(x="day", y="total_bill", hue="smoker", data=tips, palette="muted")
seaborn.set(style = 'whitegrid')
fmri = seaborn.load_dataset("fmri")
seaborn.violinplot(x ="timepoint",y ="signal", data = fmri)
seaborn.set(style = 'whitegrid')
fmri = seaborn.load_dataset("fmri")
seaborn.violinplot(x ="timepoint", y ="signal", hue ="region", style ="event", data = fmri)
seaborn.set(style = 'whitegrid') 
tip = seaborn.load_dataset('tips')
seaborn.violinplot(x ='day', y ='tip', data = tip)
35
Q

seaborn.displot(data=None, *, x=None, y=None, hue=None, row=None, col=None, weights=None, kind=’hist’, rug=False, rug_kws=None, log_scale=None, legend=True, palette=None, hue_order=None, hue_norm=None, color=None, col_wrap=None, row_order=None, col_order=None, height=5, aspect=1, facet_kws=None, **kwargs)

A

Figure-level interface for drawing distribution plots onto a FacetGrid.

penguins = sns.load_dataset("penguins")
sns.displot(data=penguins, x="flipper_length_mm")
sns.displot(data=penguins, x="flipper_length_mm", kind="kde")
sns.displot(data=penguins, x="flipper_length_mm", y="bill_length_mm")
36
Q

seaborn.jointplot(*, x=None, y=None, data=None, kind=’scatter’, color=None, height=6, ratio=5, space=0.2, dropna=False, xlim=None, ylim=None, marginal_ticks=False, joint_kws=None, marginal_kws=None, hue=None, palette=None, hue_order=None, hue_norm=None, **kwargs)

A

draw jointplot with

Draw a plot of two variables with bivariate and univariate graphs.

penguins = sns.load_dataset("penguins")
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm")
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")
data = sns.load_dataset("attention")
# hex kind
sns.jointplot(x = "solutions", y = "score", kind = "hex", data = data)
# show the plot
plt.show()
data = sns.load_dataset("exercise")
# draw jointplot with   # kde kind
sns.jointplot(x = "id", y = "pulse", kind = "kde", data = data)
# Show the plot
plt.show()
37
Q

seaborn.rugplot(x=None, *, height=0.025, axis=None, ax=None, data=None, y=None, hue=None, palette=None, hue_order=None, hue_norm=None, expand_margins=True, legend=True, a=None, **kwargs)

A

Plot marginal distributions by drawing ticks along the x and y axes. This function is intended to complement other plots by showing the location of individual observations in an unobstrusive way.

tips = sns.load_dataset("tips")
sns.kdeplot(data=tips, x="total_bill")
sns.rugplot(data=tips, x="total_bill")
sns.scatterplot(data=tips, x="total_bill", y="tip")
sns.rugplot(data=tips, x="total_bill", y="tip")
sns.scatterplot(data=tips, x="total_bill", y="tip")
sns.rugplot(data=tips, x="total_bill", y="tip", height=.1)
sns.scatterplot(data=tips, x="total_bill", y="tip")
sns.rugplot(data=tips, x="total_bill", y="tip", height=-.02, clip_on=False)
diamonds = sns.load_dataset("diamonds")
sns.scatterplot(data=diamonds, x="carat", y="price", s=5)
sns.rugplot(data=diamonds, x="carat", y="price", lw=1, alpha=.005)
38
Q

seaborn.lineplot(*, x=None, y=None, hue=None, size=None, style=None, data=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, dashes=True, markers=None, style_order=None, units=None, estimator=’mean’, ci=95, n_boot=1000, seed=None, sort=True, err_style=’band’, err_kws=None, legend=’auto’, ax=None, **kwargs)

A

Draw a line plot with possibility of several semantic groupings. The relationship between x and y can be shown for different subsets of the data using the hue, size, and style parameters. These parameters control what visual semantics are used to identify the different subsets.

sns.lineplot(data=flights_wide)
sns.lineplot(data=fmri, x="timepoint", y="signal", hue="region", style="event")
fmri = sns.load_dataset("fmri")
sns.lineplot( x = "timepoint", y = "signal", data = fmri);
sns.lineplot(data=museum_data["Avila Adobe"])
39
Q

seaborn.scatterplot(*, x=None, y=None, hue=None, style=None, size=None, data=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, markers=True, style_order=None, x_bins=None, y_bins=None, units=None, estimator=None, ci=95, n_boot=1000, alpha=None, x_jitter=None, y_jitter=None, legend=’auto’, ax=None, **kwargs)

A

Draw a scatter plot with possibility of several semantic groupings. The relationship between x and y can be shown for different subsets of the data using the hue, size, and style parameters.

sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time")
sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time", style="time")
seaborn.set(style='whitegrid')
fmri = seaborn.load_dataset("fmri")
seaborn.scatterplot(x="timepoint", y="signal", data=fmri)
seaborn.set(style='whitegrid')
fmri = seaborn.load_dataset("fmri")
seaborn.scatterplot(x="timepoint", y="signal", hue="region", style="event", data=fmri)
40
Q

seaborn.histplot(data=None, *, x=None, y=None, hue=None, weights=None, stat=’count’, bins=’auto’, binwidth=None, binrange=None, discrete=None, cumulative=False, common_bins=True, common_norm=True, multiple=’layer’, element=’bars’, fill=True, shrink=1, kde=False, kde_kws=None, line_kws=None, thresh=0, pthresh=None, pmax=None, cbar=False, cbar_ax=None, cbar_kws=None, palette=None, hue_order=None, hue_norm=None, color=None, log_scale=None, legend=True, ax=None, **kwargs)

A

Plot univariate or bivariate histograms to show distributions of datasets. A histogram is a classic visualization tool that represents the distribution of one or more variables by counting the number of observations that fall within disrete bins.

penguins = sns.load_dataset("penguins")
sns.histplot(data=penguins, x="flipper_length_mm")
sns.histplot(data=penguins, y="flipper_length_mm")
np.random.seed(1)
num_var = np.random.randn(1000)
num_var = pd.Series(num_var, name = "Numerical Variable")
sns.histplot(data = num_var, kde = True)
sns.histplot(data = penguins, x = "body_mass_g", kde = True)
41
Q

seaborn.stripplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, jitter=True, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor=’gray’, linewidth=0, ax=None, **kwargs)

A

Draw a scatterplot where one variable is categorical.

sns.set_theme(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.stripplot(x=tips["total_bill"])
ax = sns.stripplot(x="day", y="total_bill", data=tips)
seaborn.set(style = 'whitegrid')  
tip = seaborn.load_dataset("tips")   
seaborn.stripplot(x="day", y="total_bill", data=tip)
plt.show()
42
Q

seaborn.kdeplot(x=None, *, y=None, shade=None, vertical=False, kernel=None, bw=None, gridsize=200, cut=3, clip=None, legend=True, cumulative=False, shade_lowest=None, cbar=False, cbar_ax=None, cbar_kws=None, ax=None, weights=None, hue=None, palette=None, hue_order=None, hue_norm=None, multiple=’layer’, common_norm=True, common_grid=False, levels=10, thresh=0.05, bw_method=’scott’, bw_adjust=1, log_scale=None, color=None, fill=None, data=None, data2=None, warn_singular=True, **kwargs)

A

Plot univariate or bivariate distributions using kernel density estimation.

tips = sns.load_dataset("tips")
sns.kdeplot(data=tips, x="total_bill")
sns.kdeplot(data=tips, x="total_bill", hue="time", multiple="stack")
# data x and y axis for seaborn
x= np.random.randn(200)
y = np.random.randn(200)
# Kde for x var
sns.kdeplot(x)
sns.kdeplot(x,y)
43
Q

seaborn.kdeplot(x=None, *, y=None, shade=None, vertical=False, kernel=None, bw=None, gridsize=200, cut=3, clip=None, legend=True, cumulative=False, shade_lowest=None, cbar=False, cbar_ax=None, cbar_kws=None, ax=None, weights=None, hue=None, palette=None, hue_order=None, hue_norm=None, multiple=’layer’, common_norm=True, common_grid=False, levels=10, thresh=0.05, bw_method=’scott’, bw_adjust=1, log_scale=None, color=None, fill=None, data=None, data2=None, warn_singular=True, **kwargs)

A

Plot univariate or bivariate distributions using kernel density estimation.

tips = sns.load_dataset("tips")
sns.kdeplot(data=tips, x="total_bill")
sns.kdeplot(data=tips, x="total_bill", hue="time", multiple="stack")
# data x and y axis for seaborn
x= np.random.randn(200)
y = np.random.randn(200)
# Kde for x var
sns.kdeplot(x)
sns.kdeplot(x,y)
44
Q

seaborn.pairplot(data, *, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind=’scatter’, diag_kind=’auto’, markers=None, height=2.5, aspect=1, corner=False, dropna=False, plot_kws=None, diag_kws=None, grid_kws=None, size=None)

A

Plot pairwise relationships in a dataset.

penguins = sns.load_dataset("penguins")
sns.pairplot(penguins)
sns.pairplot(penguins, hue="species")
df = seaborn.load_dataset('tips')
seaborn.pairplot(df, hue ='day')
plt.show()
45
Q

seaborn.countplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, dodge=True, ax=None, **kwargs)

A

Show the counts of observations in each categorical bin using bars.

sns.set_theme(style="darkgrid")
titanic = sns.load_dataset("titanic")
ax = sns.countplot(x="class", data=titanic)
ax = sns.countplot(x="class", hue="who", data=titanic)
g = sns.catplot(x="class", hue="who", col="survived", data=titanic, kind="count", height=4, aspect=.7)
df = sns.load_dataset('tips')
sns.countplot(x ='sex', hue = "smoker", data = df)
plt.show()
df = sns.load_dataset('tips')
sns.countplot(y ='sex', hue = "smoker", data = df)
plt.show()
46
Q

set.union()

A

method returns a set that contains all items from the original set, and all items from the specified set(s). You can specify as many sets you want, separated by commas.

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.union(y) 
print(z)

👉 {'cherry', 'banana', 'microsoft', 'apple', 'google'}
47
Q

set

A

used to store multiple items in a single variable. список в котором не дубликатов.

thisset = {"apple", "banana", "cherry", "apple"}
print(thisset)
👉 {'banana', 'cherry', 'apple'}
48
Q

set.issuperset(other)

A

позволяет проверить находится ли каждый элемент последовательности other в множестве sets. Метод возвращает True, если множество sets является надмножеством итерируемого объекта other, если нет, то вернет False.

set_x = {'march', 'feb', 'may'}
list_y = ['march', 'dec', 'feb', 'may']

set_x.issuperset(list_y)
👉 False

set_x >= set(list_y)
👉 False

set_x.add('dec')
set_x.issuperset(list_y)
👉 True
49
Q

set.discard()

A

method removes the specified item from the set. This method is different from the remove() method, because the remove() method will raise an error if the specified item does not exist, and the discard() method will not.

thisset = {"apple", "banana", "cherry"}
thisset.discard("banana")
print(thisset)
👉 {'apple', 'cherry'}
50
Q

set.intersection()

A

method returns a set that contains the similarity between two or more sets. Метод возвращает новое множество с элементами, общими для множества sets и всех итерируемых объектов other ( - произвольное число позиционных аргументов).

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.intersection(y)

print(z)
👉 {‘apple’}