from PIL import Image, ImageFont, ImageDraw 

# Allows image to be displayed in Jupyter notebook, only run in local
from IPython import display

# Open an Image from images directory
img = Image.open('images/skin1.png')
 
# Call draw Method to add 2D graphics in an image
draw = ImageDraw.Draw(img)

# Downloaded font, opened zip, dragged to fonts directory
myfont = ImageFont.truetype('fonts/Aloevera.ttf', 68)
 
# Add Text to an image, adjust coordinates/text/font/color
draw.text((120, 150), "We recommend...", font=myfont, fill=(0, 0, 0))
 
# Display edited image
img.show()

# Save image in images directory
img.save('images/skin2.png')

# Displays image in notebook
display.Image('images/skin2.png')
from PIL import Image
 
# numpy for performing batch processing and elementwise
# matrix operations efficiently
import numpy as np

# Allows image to be displayed in Jupyter notebook, only run in local
from IPython import display

display.Image("images/negatives.jpg")
from PIL import Image
 
# numpy for performing batch processing and elementwise
# matrix operations efficiently
import numpy as np

# Allows image to be displayed in Jupyter notebook, only run in local
from IPython import display
 
 
# Opening an image, and saving open image object
img = Image.open(r"images/negatives.jpg")
 
# Creating an numpy array out of the image object
img_arry = np.array(img)
 
# Maximum intensity value of the color mode
I_max = 255
 
# Subtracting 255 (max value possible in a given image
# channel) from each pixel values and storing the result
img_arry = I_max - img_arry
 
# Creating an image object from the resultant numpy array
inverted_img = Image.fromarray(img_arry)
 
# Saving the image under the name Image_negative.jpg
inverted_img.save(r"images/negatives1.jpg")


# Displays image in notebook


print("after image:")
display.Image("images/negatives1.jpg")
import pandas as pd

# reads the JSON file and converts it to a Pandas DataFrame
df = pd.read_json('files/transport.json')

print(df)
# What part of the data set needs to be cleaned?
# From PBL learning, what is a good time to clean data?  Hint, remember Garbage in, Garbage out?
    Student Grade  Student Age Transport
0              12           17       Car
1              12           17      Walk
2              12           19       Bus
3              12           17       Bus
4              12           16       Car
5              12           16       Car
6              12           17       Car
7              12           17       Bus
8              11           17       Car
9              12           17       Car
10             12           16       Car
11             11           16       Car
12             12           16     Skate
13             11           32       Car
14             12           18       Car
15             12           15       Car
16             12           17      Walk
17             11           16       Car
18             12           18       Car
19             12           16      Walk
20             12           18      Walk
df2 = df["Student Age"].mean()
print("mean:", df2)

df3 = df["Student Age"].min()
print("min:", df3)

df4 = df["Student Age"].max()
print("max:", df4)

df5 = df["Student Age"].median()
print("median:", df5)

df6 = df["Student Age"].mode()
print("mode:", df6)
mean: 17.523809523809526
min: 15
max: 32
median: 17.0
mode: 0    17
Name: Student Age, dtype: int64