[英]How to visualize saved data after extracting it from the dataset
First idea is create 3 columns DataFrame
by # Series.reset_index
, remove duplicates by DataFrame.drop_duplicates
and reshape by DataFrame.pivot
:第一个想法是通过 #
Series.reset_index
创建3 columns DataFrame
通过Series.reset_index
删除重复DataFrame.drop_duplicates
并通过DataFrame.pivot
重塑:
df = (temp_1.reset_index(name='count')
.drop_duplicates('release_year')
.pivot('release_year','genres','count'))
Or remove duplicates in MultiIndex
by Index.get_level_values
with Index.duplicated
and boolean indexing
, reshape by Series.unstack
and last create 3 columns DataFrame
:或删除重复的
MultiIndex
由Index.get_level_values
与Index.duplicated
和boolean indexing
通过,重塑Series.unstack
和最后创建3 columns DataFrame
:
df = (temp_1[~temp_1.index.get_level_values('release_year').duplicated()]
.unstack()
.reset_index(name='count'))
Last plot by DataFrame.plot.bar
:最后由
DataFrame.plot.bar
:
df.plot.bar()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.