Bonjour à tous, je me trouve devant un soucis depuis 2 jours que je peine à résoudre. C'est pourquoi je fais appel à vous.

Voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#Import modules we need
import pandas as pd
import numpy as np
import os
import matplotlib.pyplot as plt
 
#Opening file with data
os.chdir("C:/Users/mariu/PycharmProjects/examunamur2018/Data")
coffee = open("Coffeebar_2013-2017.csv", "r")
 
#organize the csv file and delimit all data by column
df = pd.read_csv(coffee, ";")
 
#Seperates the TIME column in two different columns, DATE and HOUR and converts DATE in datetime format
df['HOUR'] = df['TIME'].str[-8:]
df['DATE'] = pd.to_datetime(df['TIME'].str[0:10])
df.index = df['DATE']
del df['TIME']
del df['DATE']
df = df[['HOUR', 'CUSTOMER', 'DRINKS', 'FOOD']]
 
#Prints the diffentt foods, drinks and the number of customers
kind_of_food = df.FOOD.unique()
kinf_of_drinks = df.DRINKS.unique()
nbr_of_unique_customers = df.CUSTOMER.nunique()
print(kind_of_food)
print(kinf_of_drinks)
print(nbr_of_unique_customers)
 
 
#Prints the whole file
print(df)
 
#Point 2
 
#Create the graph for food sold every year
amount_food_2013 = df['2013']['FOOD'].count()
amount_food_2014 = df['2014']['FOOD'].count()
amount_food_2015 = df['2015']['FOOD'].count()
amount_food_2016 = df['2016']['FOOD'].count()
amount_food_2017 = df['2017']['FOOD'].count()
 
data_food = {'YEAR': ['2013', '2014', '2015', '2016', '2017'],
             'AMOUNT FOOD': [amount_food_2013, amount_food_2014, amount_food_2015, amount_food_2016, amount_food_2017]}
food_sold_year = pd.DataFrame(data_food, columns = ['YEAR', 'AMOUNT FOOD'])
print(food_sold_year)
 
graph_food = food_sold_year.plot(x = 'YEAR', y = 'AMOUNT FOOD', title = 'Amount of food sold each year')
graph_food.set_xlabel("YEAR")
graph_food.set_ylabel("AMOUNT OF FOOD")
plt.show()
 
#Create the graph for drinks sold every year
amount_drink_2013 = df['2013']['DRINKS'].count()
amount_drink_2014 = df['2014']['DRINKS'].count()
amount_drink_2015 = df['2015']['DRINKS'].count()
amount_drink_2016 = df['2016']['DRINKS'].count()
amount_drink_2017 = df['2017']['DRINKS'].count()
 
data_drinks = {'YEAR': ['2013', '2014', '2015', '2016', '2017'],
             'AMOUNT DRINKS': [amount_drink_2013, amount_drink_2014, amount_drink_2015, amount_drink_2016, amount_drink_2017]}
drinks_sold_year = pd.DataFrame(data_drinks, columns = ['YEAR', 'AMOUNT DRINKS'])
print(drinks_sold_year)
 
graph_drinks = drinks_sold_year.plot(x = 'YEAR', y = 'AMOUNT DRINKS', title = 'Amount of drinks sold each year')
graph_drinks.set_xlabel("YEAR")
graph_drinks.set_ylabel("AMOUNT OF DRINKS")
plt.show()
 
#Starting point 3 because of issue at point 2
#Gives the amount of food
amount_food = df['FOOD'].value_counts()
print(amount_food)
 
#Gives the amount of drinks
amount_drinks = df['DRINKS'].value_counts()
print(amount_drinks)
 
#Gives the total of sold food
total_food = df['FOOD'].count()
print(total_food)
 
#Gives the total of sold drinks
total_drinks = df['DRINKS'].count()
print(total_drinks)
 
 
#Defines the different unique hours we can get
 
unique_hour = df.HOUR.unique()
print(unique_hour)


Le problème est que, si j'enlève de ce code l'importation du module matplotlib.pyplot , alors le code m'affiche ce que je veux (excepté les graphes crées grace au module).

Mais lorsque le module est importé comme dans le haut du code ici, plus rien de s'affiche dans ma console, pas même les print classiques... Voici ce qui sort dans ma console.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
C:\Users\mariu\Anaconda3\python.exe C:/Users/mariu/PycharmProjects/examenunamur/Exploratory.py
 
Process finished with exit code -1073741819 (0xC0000005)
Est-ce que quelqu'un peut m'aider à résoudre ce problème svp ?

Un tout grand merci,

Marius (jeune étudiant)