python - 有没有办法在图表中“切换行/列”数据?
问题描述
我正在创建一个图表,并希望在 PowerPoint 中打开图表之前切换我输入的数据的行和列。该系列的格式和分组不正确,图表以这种方式没有任何意义。
我正在使用我理解难以操作的元组,所以如果我缺少一个命令来简单地切换行/列?这似乎是最简单的解决方案。
x3 = Inches(0.3)
y3 = Inches(3.7)
cx3 = Inches(1.25)
cy3 = Inches(1.25)
chart_data_marriage = CategoryChartData()
chart_data_marriage.categories = ['Married HH', 'Married Footprint']
demographics['Profile List Title'] = demographics['Profile List Title'].str.strip()
tuple_married1 = demographics['Family Renters : Users/100 HHs']
tuple_married_footprint = demographics['Profile List: Total Profile Users/100 HHs']
tuple_married1.drop([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95], inplace = True)
tuple_married_footprint.drop([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95], inplace = True)
chart_data_marriage.add_series('Family Renters : Users/100 HHs', (tuple_married1))
chart_data_marriage.add_series('Profile List: Total Profile Users/100 HHs', (tuple_married_footprint))
marriagechart = storyboard1.shapes.add_chart(XL_CHART_TYPE.DOUGHNUT, x3, y3, cx3, cy3, chart_data_marriage).chart
marriagechart.has_legend = False
在两者中tuple_married1
,tuple_married_footprint
我拥有创建圆环图所需的数据,因此只需以正确的顺序格式化系列即可。同样,像现在存在于 PowerPoint 中的按钮这样的切换行和列命令将是理想的,否则可能需要更复杂的解决方案。
解决方案
如果您的数据来自 Pandas 数据框,您可以demographics.T
在将数据移至pptx
.
推荐阅读
- linux - 重塑矩阵的特定维度
- arrays - 您可以将 Matlab 数组和结构的复合数据存储和查询到数据库中吗?
- android - Google Play 应用内购买 - querySkuDetailsAsync 不返回状态(活动/非活动)
- django - 如何将 json 传递给序列化程序以存储在模型中
- ifc - 如何查询ifc文件?
- javascript - Geolocation API 坐标返回 Mozilla Firefox 66 的 NaN
- css - 使用 flex 将 react-select 与单行中的其他元素对齐
- ios - 无法在发布请求ios swift中发布参数
- android - LiveData 插入 Room 数据库后未更新
- wicket - 如何根据特定条件聚焦列表视图中的列表项?