import matplotlib pyplot as plt import seaborn as sns from pandas plot

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import matplotlib.pyplot as plt
import seaborn as sns
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
def avg_area(df):
res = pd.np.mean(df['price']/df['floor_area'])
return res
q1 = pricesdf.merge(estatesdf.loc[(estatesdf['brick'] == True) & (estatesdf['new_building'] == False)])\
[['ts', 'price','floor_area']].groupby('ts').apply(avg_area)
q2 = pricesdf.merge(estatesdf.loc[estatesdf['panel'] == True])\
[['ts', 'price','floor_area']].groupby('ts').apply(avg_area)
q3 = pricesdf.merge(estatesdf.loc[estatesdf['new_building'] == True])\
[['ts', 'price', 'floor_area']].groupby('ts').apply(avg_area)
q4 = pricesdf.merge(estatesdf)\
[['ts', 'price', 'floor_area']].groupby('ts').apply(avg_area)
q = pd.concat([q1,q2,q3,q4],axis=1)
q.columns= ['cihla','panel','novostavba','vse']
display(q)
sns.set(style='darkgrid')
sns.lineplot(data=q)