I want to play with the data of house prices in Barcelona with Pandas, but there are amounts separated as square meters and monthly fees in the dataset, how can I get the prices of houses with only monthly amounts specifically?
Here is some data:
COLUMNS = ['Year', 'Trimester', 'District', 'Neighbourhood', 'Average _rent','Price']
Sample Code:
import pandas as pd
import numpy as np
data = pd.read_csv('Barcelona_rent_price.csv')
print(data['Price']) # i just only want to get monthly prices
print(np.mean(data['Price']))
Hope it works for your solution, we need to group by for year and month
import pandas as pd
df = pd.read_csv('./Barcelona_rent_price.csv')
df[df['Average _rent'] == 'average rent (euro/month)'].groupby(by=['Year', 'Average _rent']).agg({'Price': 'mean'})