матрица с месяцами и годами и соответствующей прибылью - PullRequest
1 голос
/ 08 марта 2019

Я хочу иметь матрицу с номером месяца на оси X и годом на оси Y.Я сделал это, но хочу, чтобы прибыль также отображалась.Таким образом, содержание внутри матрицы - это прибыль.как я это сделал?это мой код:

import numpy as np
import pandas as pd

%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()

datafile = 'datasets/ga1-movies.csv'
df_movies = pd.read_csv(datafile)
df_movies['Profit'] = df_movies['Worldwide Gross'] - df_movies['Production Budget']

df_movies_grouped = df_movies.groupby(["Release Year", "Release Month"]).count().reset_index()
df_movies_matrix = df_movies_grouped.pivot("Release Year", "Release Month", "Profit")

df_movies_matrix

это мой вывод

месяц выпуска 1 2 3 4 5 6 7 8 9 10 11 12 год выпуска
1939 NaN NaN NaN NaN NaN NaNNaN 1.0 NaN NaN NaN NaN 1973 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1.0 1977 NaN NaN NaN NaN NaN NaN NaN NaN NaN 1.0 NaN 1978 NaN NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaN NaN 1981 NaNNaN 2,0 NaN NaN NaN NaN NaN NaN 1982 NaN NaN NaN NaN NaN 1,0 NaN NaN NaN NaN NaN NaN 1984 NaN NaN NaN NaN NaN 1,0 NaN NaN NaN NaN NaN NaN 1985 NaN NaN NaN NaN NaN NaN 1,0 NaN NaN NaN NaN 1986 NaN NaN 1986 NaN NaNNaN NaN 1.0 NaN NaN NaN NaN NaN NaN NaN 1989 NaN NaN NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaN 1990 NaN NaN NaN NaN NaN NaN 1.0 NaN NaN NaN NaN 1992 г. NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaN 1993NaN NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaN 1994 NaN NaN NaN NaN NaN 1.0 1.0 NaN NaN NaN NaN NaN 1995 NaN NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaN 1996 NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaNNaN 1997 NaN NaN NaN NaN 4.0 7.0 5,0 8,0 6,0 6,0 11,0 9,0 1998 4,0 4,0 7,0 6,0 6,0 6,0 9,0 5,0 6,0 10,0 12,0 13,0 1999 4,0 9,0 11,0 6,0 4,0 7,0 12,0 15,0 10,0 17,0 9,0 14,0 2000 6,0 10,0 14,0 11,0 9,0 8,0 7,0 10,0 13,0 14,0 11,0 17,0 2001 5,013,0 11,0 5,0 9,0 11,0 15,0 8,0 10,0 11,0 13,0 2002 5,0 11,0 11,0 9,0 11,0 9,0 8,0 9,0 11,0 14,0 12,0 15,0 2003 5,0 8,0 10,0 11,0 7,0 7,0 9,0 8,0 9,0 8,0 10,0 10,0 2004 8,0 7,0 9,0 14,0 9,0 13,0 9,0 8,0 8,0 9,0 9,0 14,0 20056,0 9,0 11,0 9,0 7,0 5,0 10,0 12,0 12,0 11,0 9,0 8,0 2006 7,0 9,0 16,0 12,0 9,0 12,0 8,0 10,0 11,0 13,0 10,0 15,0 2007 4,0 8,0 12,0 6,0 8,0 12,0 8,0 12,0 11,0 9,0 13,0 11,0 2008 10,0 14,0 10,0 12,0 6,0 7,0 8,0 14,0 13,0 22,0 10,017,0 2009 9,0 4,0 9,0 5,0 9,0 10,0 9,0 11,0 17,0 12,0 12,0 15,0 2010 9,0 8,0 15,0 12,0 8,0 12,0 11,0 11,0 13,0 13,0 13,0 13,0 14,0 2011 7,0 8,0 10,0 14,0 12,0 10,0 11,0 17,0 19,0 15,0 12,0 13,0 2012 10,0 10,0 9,0 12,0 9,0 13,0 8,0 12,0 14,013,0 12,0 6,0 2013 12,0 8,0 14,0 8,0 8,0 8,0 14,0 11,0 9,0 9,0 15,0 12,0 2014 9,0 11,0 10,012,0 7,0 8,0 11,0 12,0 6,0 15,0 9,0 12,0 2015 8,0 8,0 9,0 11,0 8,0 5,0 11,0 6,0 10,0 10,0 13,0 11,0 2016 8,0 9,0 7,0 7,0 6,0 8,0 8,0 3,0 NaN 1,0 NaN NaN 2017 NaN NaN NaN 2,0 NaN NaN NaN NaN NaN NaN NaN

...