<jupyter_start><jupyter_text>Build a movie reviewed<jupyter_code># Write a program that recomends movies from data that you enter.

# Step 1
# Each movie consist of a name, a genre, a rating (1 to 5) and the person who reviewed the movie.

# Ideas

# Create a DataFrame
# Create a database (text file)
# Create a user interface


# Later 

# Collect data from the internet<jupyter_output><empty_output><jupyter_text>Movie<jupyter_code>import pandas as pd

path = "/Users/Pippo/Desktop/python_examples/Movie_recomender/"


df = pd.read_excel('movie_recommendations.xlsx')
df

df.sort_values('Rating', ascending=False).head(1)
df.sort_values('Rating', ascending=False).head(5)

df.sort_values('Rating', ascending=False, inplace=True)
print(df.head(5).sample(1))

df.head(3)
df.head(10)
# produce clean unique index
df.sort_values(by=['Name', 'Genre', 'Reviewer'], inplace=True)
clean = df.drop_duplicates().dropna()
df
long = clean.set_index(['Name', 'Genre', 'Reviewer'])
long

# mean rating per genre
print(long.unstack(1).mean())

print('Enter a genre (or leave it empty): ', end='')
genre = input()

if genre:
    g = df[df['Genre'] == genre]
else: 
    g = df
    
result = g.sort_values('Rating', ascending=False)
print(result.head(3).sample(1))
print("Enter a rating number 1 - 5 (or leave it empty): ", end="")
rating = float(input())

if rating:
    r = df[df['Rating'] == rating]
else:
    r = df
    
print("Enter a reviewer (or leave it empty): ", end="")
reviewer = input()

if reviewer:
    re = r[r['Reviewer'] == reviewer]
else:
    re = r

print("Enter a genre (or leave it empty): ", end="")
genre = input()

if genre:
    g = re[re['Genre'] == genre]
else:
    g = re


if g.shape[0] > 0:
    result = g.sort_values('Rating', ascending=False)
    print(result.head(3).sample(1))
else:
    print("Sorry, no results!")<jupyter_output>Enter a rating number 1 - 5 (or leave it empty): 1
Enter a reviewer (or leave it empty): Drama
Enter a genre (or leave it empty): Paul
Sorry, no results!
StarcoderdataJupyterStructuredCleanDedup