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('ZenZine/python/started/sample_data.csv') | |
# Чтение данных из веба | |
data_url = "https://github.com/Bookoff/ZenZine/raw/master/python/started/sample_data.csv" | |
df = pd.read_csv(data_url) |
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
# Первые несколько строк данных | |
print df.head() | |
# ВЫВОД | |
# Alpha Beta Gamma Tetta Zeta | |
# 0 1243 2934 148 3300 10553 | |
# 1 4158 9235 4287 8063 35257 | |
# 2 1787 1922 1955 1074 4544 | |
# 3 17152 14501 3536 19607 31687 |
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
# Получение названий столбцов | |
print df.columns | |
# ВЫВОД | |
# Index([u'Alpha', u'Beta', u'Gamma', u'Tetta', u'Zeta'], dtype='object') | |
# Получение названий строк или индекса | |
print df.index | |
# ВЫВОД |
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
# Транспонирование данных | |
print df.T | |
# ВЫВОД | |
# 0 1 2 3 4 5 6 7 8 9 10 \ | |
# Alpha 1243 4158 1787 17152 1266 5576 927 21540 1039 5424 981 | |
# Beta 2934 9235 1922 14501 2385 7452 1099 17038 1382 10588 1311 | |
# Gamma 148 4287 1955 3536 2530 771 2796 2463 2592 1064 2560 | |
# Tetta 3300 8063 1074 19607 3315 13134 5134 14226 6842 13828 5078 | |
# Zeta 10553 35257 4544 31687 8520 28252 3106 36238 4973 40140 3466 |
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
print df.ix[:, 0].head() | |
# ВЫВОД | |
# 0 1243 | |
# 1 4158 | |
# 2 1787 | |
# 3 17152 | |
# 4 1266 | |
# Name: Alpha, dtype: int64 |
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
print df.ix[10:20, 0:3] | |
# ВЫВОД | |
# Alpha Beta Gamma | |
# 10 981 1311 2560 | |
# 11 27366 15093 3039 | |
# 12 1100 1701 2382 | |
# 13 7212 11001 1088 | |
# 14 1048 1427 2847 |
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
print df.drop(df.columns[[1, 2]], axis = 1).head() | |
# ВЫВОД | |
# Alpha Tetta Zeta | |
# 0 1243 3300 10553 | |
# 1 4158 8063 35257 | |
# 2 1787 1074 4544 | |
# 3 17152 19607 31687 | |
# 4 1266 3315 8520 |
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
print df.describe() | |
# ВЫВОД | |
# Alpha Beta Gamma Tetta Zeta | |
# count 79.000000 79.000000 79.000000 79.000000 79.000000 | |
# mean 12874.379747 16860.645570 3237.392405 12414.620253 30446.417722 | |
# std 16746.466945 15448.153794 1588.536429 5034.282019 22245.707692 | |
# min 927.000000 401.000000 148.000000 1074.000000 2346.000000 | |
# 25% 1524.000000 3435.500000 2328.000000 8205.000000 8601.500000 |
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
from scipy import stats as ss | |
# Проводим одновыборочный t-тест для мат. ожидания 15000 | |
print ss.ttest_1samp(a = df.ix[:, 'Alpha'], popmean = 15000) | |
# ВЫВОД | |
# (-1.1281738488299586, 0.26270472069109496) |
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
print ss.ttest_1samp(a = df, popmean = 15000) | |
# ВЫВОД | |
# (array([ -1.12817385, 1.07053437, -65.81425599, -4.564575 , 6.17156198]), | |
# array([ 2.62704721e-01, 2.87680340e-01, 4.15643528e-70, 1.83764399e-05, 2.82461897e-08])) |
OlderNewer