and I want to have scatter plot that have the monthly_base_price as x axis and avg_vacancy of all the shared bedrooms in one color and avg_vacancy of all the private bedrooms in one color.
First I am reseting the index and creating 2 groups for shared and private with query
.
shared = df.reset_index().query("bedrooms == 'shared'")
private = df.reset_index().query("bedrooms == 'private'")
Then I plot a chart for each of the groups.
ax = shared.plot(kind='scatter', x='monthly_base_price', y='avg_vacancy', label='shared')
private.plot(kind='scatter', x='monthly_base_price', y='avg_vacancy', label='privacy', ax=ax)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.