<jupyter_start><jupyter_text>Откуда данные: https://www.kaggle.com/c/titanic<jupyter_code>!ls -lh<jupyter_output><empty_output><jupyter_text>---<jupyter_code>import pandas as pd
train = pd.read_csv('00_titanic_train.csv')
train<jupyter_output><empty_output><jupyter_text>Описание данных| Variable | Definition | Key ||----------|------------|-----||survival | Survival | 0 = No  1 = Yes||pclass | Ticket class | 1 = 1st = Upper  2 = 2nd = Middle  3 = 3rd = Lower ||sex | Sex | ||Age | Age in years |  ||sibsp |  of siblings  spouses aboard the Titanic | ||parch |  of parents  children aboard the Titanic | ||ticket | Ticket number | ||fare | Passenger fare | ||cabin | Cabin number | ||embarked | Port of Embarkation | C = Cherbourg  Q = Queenstown  S = Southampton| age    Age is fractional if less than 1. If the age is estimated, is it in the form of xx.5sibsp    The dataset defines family relations in this way...    Sibling = brother, sister, stepbrother, stepsister    Spouse = husband, wife (mistresses and fiancés were ignored)parch    The dataset defines family relations in this way...    Parent = mother, father    Child = daughter, son, stepdaughter, stepson    Some children travelled only with a nanny, therefore parch=0 for them. ---  pandas: head, tail https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.head.html DataFrame.head(n=5)&nbsp;&nbsp;&nbsp;&nbsp;Return the first n rows.<jupyter_code>train.head()
train.head(2)
train.tail(2)<jupyter_output><empty_output><jupyter_text>---  pandas: shape<jupyter_code>train.shape<jupyter_output><empty_output><jupyter_text>---  pandas: columns, index<jupyter_code>train.columns
train.index<jupyter_output><empty_output><jupyter_text>pandas: T<jupyter_code>train.head(4).T
transpose_train = train.T
transpose_train
## pandas: columns, index, что теперь columns, а что index в transpose_train. Проверим на практике.

## ваш код :-)<jupyter_output><empty_output><jupyter_text>---  pandas: info<jupyter_code>train.info()<jupyter_output><empty_output><jupyter_text>---  pandas: describe<jupyter_code>train.describe()
train.describe(percentiles=[0.99])<jupyter_output><empty_output><jupyter_text>---  pandas: Series<jupyter_code>train['Name']
list(train['Name'])
## как пройти циклом for по всем именам? и вывести например всех 'John'

# ваш код :-)<jupyter_output><empty_output><jupyter_text>--- pandas: map<jupyter_code>'skillfactory'
len('skillfactory')
train['Name'].map(len)
def is_Mr(s):
    return 'Mr.' in s
train['Name'].map(is_Mr)
train['Name'].map(lambda s: 'Mr' in s)
train['is_Mr'] = train['Name'].map(lambda s: 'Mr.' in s)
train.head()
train['Name'].is_unique
train['PassengerId'].is_unique
train['Age'].is_unique<jupyter_output><empty_output><jupyter_text>---  pandas: select columns<jupyter_code>train.head()
train[['PassengerId', 'Embarked', 'Pclass']].head()<jupyter_output><empty_output><jupyter_text>---  pandas: select rows<jupyter_code>train[train['Sex'] == 'male'].head()
train[train['PassengerId'] == 666]
train[train['Age'].isnull()].head()
train[~train['Age'].isnull()].head()
train[train['Embarked'].isin(['Q', 'C'])].head()
## выбрать только те строки, где имя содержит Name

# ваш код :-)

train[
    train['Embarked'].isin(['Q', 'C']) & (train['Age'] > 40)
].head()
train[
    train['Embarked'].isin(['Q', 'C']) | (train['Age'] > 40)
].head()<jupyter_output><empty_output><jupyter_text>---  pandas: loc, iloc<jupyter_code>tmp = train[
    train['Embarked'].isin(['Q', 'C']) & (train['Age'] > 40)
].head()
tmp
tmp.loc[54:116, 'Pclass':'Parch']
tmp.iloc[1:4, 2:8]<jupyter_output><empty_output><jupyter_text>---  pandas: sort<jupyter_code>train.sort_values('Name')
train.sort_values('Fare', ascending=False)<jupyter_output><empty_output><jupyter_text>---  pandas: create from list<jupyter_code>pd.DataFrame(
    [
        [1,3],
        [2,4],
        [3,5]
    ]
)
df_embarked = pd.DataFrame(
    [
        ['C', 'Cherbourg'],
        ['Q', 'Queenstown'],
        ['S', 'Southampton']
    ],
    columns=['id', 'City']
)
df_embarked<jupyter_output><empty_output><jupyter_text>---  pandas: merge https://pandas.pydata.org/pandas-docs/stable/merging.html<jupyter_code>pd.merge(
    train,
    df_embarked,
    left_on='Embarked',
    right_on='id'
)<jupyter_output><empty_output><jupyter_text>---  pandas: groupby<jupyter_code>train[['Age', 'Sex']].groupby('Sex').median()<jupyter_output><empty_output><jupyter_text>pandas: pivot_table http://pbpython.com/images/pivot-table-datasheet.png<jupyter_code>train.pivot_table('PassengerId', 'Pclass', 'Survived', 'count')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1770720034805308, 'fraction_numerical': 0.009571459647596259, 'mean_word_length': 5.53125, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 76, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, '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': '18', 'dir': 'jupyter-structured-clean-dedup', 'id': '416244', 'license': 'Naumen', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1756, 'n_words': 315, 'path': 'hw01/lesson_01/00_titanic.ipynb', 'repo_name': 'rojaster/sfml', 'size': '4597'}