I'm following the answer for this StackOverflow post to group a column of years by decades to make it easier for me to visualize later, but I'm not getting the same results. It seems like when DSM did it, it yielded integers for years, while mine is yielding floats for years.
I've implemented:
p_b['yr_built'] = pd.to_datetime(df['yr_built'], format='%Y', errors='coerce').dt.to_period('Y')
p_b= p_b.set_index('yr_built')
p_b1= p_b.groupby((p_b.index.year/10)*10).mean()
My Results: Picture of Results
您应该添加另一个 /,即 p_b.index.year//。
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.