Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# импортируем библиотеку | |
import numpy as np | |
# списки | |
L = [1, 2, 4, 0] | |
E = [[1, 0, 3], [3, 6, 7], []] | |
D = [[1, 3, 6], ['a', 'b', 'c']] | |
# массивы numpy | |
A = np.array(L) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# загрузить библиотеку | |
import matplotlib.pyplot as plt | |
% matplotlib inline | |
# создать простой график на основе двух списков | |
X = [-2, -0.5, 0, 2, 5, 8, 9, 10] | |
Y = [4, 0.25, 0, 4, 25, 64, 81, 100] | |
Z = [10, 9, 8, 5, 2, 0, -1, -2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# загрузить библиотеку | |
import matplotlib.pyplot as plt | |
# создать простой график на основе двух списков | |
X = [-2, -0.5, 0, 2, 5, 8, 9, 10] | |
Y = [4, 0.25, 0, 4, 25, 64, 81, 100] | |
plt.plot(X,Y) | |
plt.plot(X, Y, 'lightblue') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# загрузить stats из scipy | |
# pandas - для базы данных | |
import scipy.stats as st | |
import pandas as pd | |
# загрузить базу | |
df = pd.read_csv('swiss.csv') | |
# работа | |
df[df.Catholic > 50] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# загружаем txt-file | |
f = open('mytext.txt', 'r', encoding = 'UTF-8') | |
f.readlines() | |
lines = f.readlines() | |
lines | |
# ха-ха | |
f.readlines() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# маленькая база с текстами | |
import pandas as pd | |
df = pd.read_csv('articles.csv', encoding= 'UTF-8') | |
df | |
df.text[3] | |
# пока сами - взять функцию normalize() из прошлой части | |
# и создать новый столбец с text_norm с нормализованным текстом | |
# с помощью apply |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.read_csv('articles.csv', encoding= 'UTF-8') | |
# normalization | |
import string | |
def normalize(x): | |
to_remove = string.punctuation + '«»—' | |
translator = str.maketrans('', '', to_remove) | |
res = x.translate(translator) | |
res = res.lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student: | |
def __init__(self, name="name", mark=0, age=None): | |
self.name = name | |
self.mark = mark | |
self.age = age | |
def mark5(self): | |
if self.mark >= 8: | |
m = 5 | |
if self.mark in [6, 7]: |
OlderNewer