如何获取我的python代码每一行中的内存使用情况

时间:2019-03-10 17:48:55

标签: python python-3.x

我有下面的python代码,我想获取每一行的内存使用情况,

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data, cbar_kws={'ticks': [0, 2, 4, 6, 8, 10]}, vmin=0, vmax=10) 
plt.show()


#Create a DataFrame
d = {'Name':['Alisa','Bobby','Cathrine','Madonna','Rocky','Sebastian','Jaqluine',
   'Rahul','David','Andrew','Ajay','Teresa'],
   'Score1':[62,47,55,74,31,77,85,63,42,32,71,57],
   'Score2':[89,87,67,55,47,72,76,79,44,92,99,69]}


df = pd.DataFrame(d)
col_mean=df.mean()
col_std=df.std()
get_disc=df.describe()

我在下面尝试过,但是我什么也没得到。

from memory_profiler import profile
@profile
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data, cbar_kws={'ticks': [0, 2, 4, 6, 8, 10]}, vmin=0, vmax=10) 
plt.show()


#Create a DataFrame
d = {'Name':['Alisa','Bobby','Cathrine','Madonna','Rocky','Sebastian','Jaqluine',
   'Rahul','David','Andrew','Ajay','Teresa'],
   'Score1':[62,47,55,74,31,77,85,63,42,32,71,57],
   'Score2':[89,87,67,55,47,72,76,79,44,92,99,69]}


df = pd.DataFrame(d)
col_mean=df.mean()
col_std=df.std()
get_disc=df.describe()

0 个答案:

没有答案