Beispiel #1
0
 def read_image(image_path, is_raw=False):
     if is_raw:
         try:
             img = StringIO(image_path)
         except TypeError:
             img = BytesIO(image_path)
         img = Image.open(img).convert('RGB')
     else:
         img = Image.open(image_path).convert('RGB')
     img_copy = img.copy()
     img.close()
     return img_copy
7         no       1                 male
8         no       2                 male
9         no       2                 male
10        no       1                 male
11        no       0                 female
"""
data = StringIO(data)
data.seek(0)

data = pd.read_csv(data, sep=' ', skipinitialspace=True, index_col='PersonID')
data.info()
# %%
"""
genero la tabella dei conteggi
"""
data_ = data.copy()
data_['Intercept'] = 1
info_df_ = data_.groupby(['Sex', 'No_of_Children', 'Married'])['Intercept'].count()
print(info_df_)

# %%
url = "http://facweb.cs.depaul.edu/mobasher/classes/csc478/Data/titanic-trimmed.csv"
titanic = pd.read_csv(url)
titanic.head(10)
titanic['Intercept'] = 1
titanic['survived'] = titanic['survived'].replace({0:'No', 1:'Yes'})
info_df_ = titanic.groupby(['pclass', 'sex', 'survived'])['Intercept'].count()


# %%
"""