Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
C
Coding project
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Adrien Payen
Coding project
Validations
f14b2969
Valider
f14b2969
rédigé
1 year ago
par
Adrien Payen
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
first part 90% done
parent
343eefbf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
projet_en_groupe/algorithme_netflix.py
+51
-59
51 ajouts, 59 suppressions
projet_en_groupe/algorithme_netflix.py
avec
51 ajouts
et
59 suppressions
projet_en_groupe/algorithme_netflix.py
+
51
−
59
Voir le fichier @
f14b2969
...
...
@@ -273,80 +273,73 @@ def specific_genre_actor(data_1):
save_to_csv
(
actor_type_data
)
else
:
print
(
f
"
No movies or series found for the actor
{
actor_input
}
and type
{
type_input
}
.
"
)
return
def
most_rated
(
data_1
):
filtered_data
=
filter_media_type
(
data_1
)
# rating
#
C
he
ck if the 'rating' column exists in the dataset
if
'
rating
'
not
in
filtered_data
.
columns
:
print
(
"
The dataset does not contain a
'
rating
'
column.
"
)
return
#
t
he
se are variables that needs to be registered in general not in a local function
notes
=
data_2
.
drop
(
'
show_id
'
,
axis
=
1
)
mean_type
=
notes
.
mean
(
axis
=
1
)
*
100
data_2
[
'
appreciation (%)
'
]
=
mean_type
# Sort the data by the 'rating' column in descending order
sorted_data
=
filtered_data
.
sort_values
(
by
=
'
rating
'
,
ascending
=
False
)
def
most_rated
(
data_1
,
data_2
)
:
# Display the top-rated movies and/or series
if
not
sorted_data
.
empty
:
print
(
"
Top-rated movies and/or series:
"
)
print
(
sorted_data
[[
'
title
'
,
'
type
'
,
'
rating
'
]].
head
(
10
))
# Display the top 10
save_to_csv
(
sorted_data
)
else
:
print
(
"
No rated movies or series found.
"
)
filtered_data
=
filter_media_type
(
data_1
)
link_between
=
pd
.
merge
(
filtered_data
,
data_2
,
on
=
'
show_id
'
)
def
most_rated_year
(
data_1
):
filtered_data
=
filter_media_type
(
data_1
)
link_between_sorted
=
link_between
.
sort_values
(
by
=
'
appreciation (%)
'
,
ascending
=
False
)
# Check if the 'rating' and 'release_year' columns exist in the dataset
if
'
rating
'
not
in
filtered_data
.
columns
or
'
release_year
'
not
in
filtered_data
.
columns
:
print
(
"
The dataset does not contain the necessary columns.
"
)
return
print
(
"
Films et séries les mieux notés :
"
)
print
(
link_between_sorted
[[
'
show_id
'
,
'
title
'
,
'
type
'
,
'
appreciation (%)
'
]])
save_to_csv
(
link_between_sorted
)
return
year_input
=
input
(
"
Enter the year to show the most rated movies and/or series:
"
)
def
most_rated_year
(
data_1
,
data_2
):
# Display all available unique release years
available_years
=
data_1
[
'
release_year
'
].
unique
()
print
(
"
Available years:
"
,
available_years
)
# Ask the user to enter a release year
year
=
input
(
"
Enter a release year:
"
)
try
:
year_input
=
int
(
year_input
)
# Convert the year to an integer
year
=
int
(
year
)
except
ValueError
:
print
(
"
Invalid input.
Please enter a valid year.
"
)
print
(
"
Please enter a valid year.
"
)
return
# Filter the data for the specified year
year_data
=
filtered_data
[
filtered_data
[
'
release_year
'
]
==
year_input
]
if
not
year_data
.
empty
:
# Sort the data by the 'rating' column in descending order
sorted_data
=
year_data
.
sort_values
(
by
=
'
rating
'
,
ascending
=
False
)
# Filter the data based on the release year
filtered_data
=
filter_media_type
(
data_1
[
data_1
[
'
release_year
'
]
==
year
])
# Display the top-rated movies and/or series in the specified year
print
(
f
"
\n
Top-rated movies and/or series in
{
year_input
}
:
"
)
print
(
sorted_data
[[
'
title
'
,
'
type
'
,
'
rating
'
]].
head
(
10
))
# Display the top 10
save_to_csv
(
sorted_data
)
else
:
print
(
f
"
No rated movies or series found for the year
{
year_input
}
.
"
)
def
most_rated_recent
(
data_1
):
filtered_data
=
filter_media_type
(
data_1
)
# Merge the DataFrames on the 'show_id' key
link_between
=
pd
.
merge
(
filtered_data
,
data_2
,
on
=
'
show_id
'
)
# Check if the 'rating' and 'date_added' columns exist in the dataset
if
'
rating
'
not
in
filtered_data
.
columns
or
'
date_added
'
not
in
filtered_data
.
columns
:
print
(
"
The dataset does not contain the necessary columns.
"
)
return
# Sort the DataFrame by the 'appreciation' column (in descending order)
link_between_sorted
=
link_between
.
sort_values
(
by
=
'
appreciation (%)
'
,
ascending
=
False
)
# Sort the data by the 'rating' column in descending order and 'date_added' in descending order
sorted_data
=
filtered_data
.
sort_values
(
by
=
[
'
rating
'
,
'
date_added
'
],
descending
=
[
False
,
True
])
print
(
f
"
Top-rated shows for the year
{
year
}
:
"
)
print
(
link_between_sorted
[[
'
show_id
'
,
'
title
'
,
'
type
'
,
'
release_year
'
,
'
appreciation (%)
'
]])
save_to_csv
(
link_between_sorted
)
return
# Display the most rated and recent movies and/or series
if
not
sorted_data
.
empty
:
print
(
"
Most rated and recent movies and/or series:
"
)
print
(
sorted_data
[[
'
title
'
,
'
type
'
,
'
rating
'
,
'
date_added
'
]].
head
(
10
))
# Display the top 10
save_to_csv
(
sorted_data
)
else
:
print
(
"
No rated and recent movies or series found.
"
)
def
most_rated_recent
(
data_1
,
data_2
):
# Merge the DataFrames on the 'show_id' key
merged_data
=
pd
.
merge
(
data_1
,
data_2
,
on
=
'
show_id
'
)
# Sort the DataFrame by the 'appreciation' column (in descending order) and 'release_year' (in descending order)
sorted_data
=
merged_data
.
sort_values
(
by
=
[
'
release_year
'
,
'
appreciation (%)
'
],
ascending
=
[
False
,
False
])
# Display the most rated and recent shows
top_20_data
=
sorted_data
.
head
(
20
)
print
(
"
Top 20 most rated and recent shows:
"
)
print
(
top_20_data
[[
'
show_id
'
,
'
title
'
,
'
type
'
,
'
release_year
'
,
'
appreciation (%)
'
]])
save_to_csv
(
top_20_data
)
return
# Example usage
...
...
@@ -360,6 +353,7 @@ def parental_code(data_1):
code_list
.
append
(
code
)
print
(
"
Here are the parental codes:
"
)
print
(
code_list
)
save_to_csv
(
code_list
)
...
...
@@ -440,9 +434,7 @@ def basic_statistics(data_1):
country_counts
=
data_1
[
'
country
'
].
str
.
split
(
'
,
'
).
explode
().
value_counts
()
print
(
"
\n
Countries that produced movies/series, sorted from most to least productive:
"
)
print
(
country_counts
)
save_to_csv
(
pd
.
DataFrame
({
'
Country Count
'
:
[
country_counts
],
'
Movies Count
'
:
[
movies_count
],
'
Series Count
'
:
[
series_count
]}),
'
counts.csv
'
)
return
# attention il faut demander à chaque fois, s'il désire enregistrer la liste sur un .csv
...
...
@@ -545,11 +537,11 @@ def action() :
elif
command
==
"
11
"
:
specific_genre_actor
(
data_1
)
elif
command
==
"
12
"
:
most_rated
(
data_1
)
most_rated
(
data_1
,
data_2
)
elif
command
==
"
13
"
:
most_rated_year
(
data_1
)
most_rated_year
(
data_1
,
data_2
)
elif
command
==
"
14
"
:
most_rated_recent
(
data_1
)
most_rated_recent
(
data_1
,
data_2
)
elif
command
==
"
15
"
:
parental_code
(
data_1
)
elif
command
==
"
16
"
:
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter