Skip to content

Instantly share code, notes, and snippets.

View allatambov's full-sized avatar

Alla Tambovtseva allatambov

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# импортируем библиотеку
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)
# загрузить библиотеку
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]
# загрузить библиотеку
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')
# загрузить stats из scipy
# pandas - для базы данных
import scipy.stats as st
import pandas as pd
# загрузить базу
df = pd.read_csv('swiss.csv')
# работа
df[df.Catholic > 50]
# загружаем txt-file
f = open('mytext.txt', 'r', encoding = 'UTF-8')
f.readlines()
lines = f.readlines()
lines
# ха-ха
f.readlines()
# маленькая база с текстами
import pandas as pd
df = pd.read_csv('articles.csv', encoding= 'UTF-8')
df
df.text[3]
# пока сами - взять функцию normalize() из прошлой части
# и создать новый столбец с text_norm с нормализованным текстом
# с помощью apply
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()
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]:
We couldn’t find that file to show.