我正在处理一些需要清除的EPA数据。看起来像这样:
# ---- ggplot with options ------------------------
server=shinyServer(function(input, output, session) {
output$plot1 <- renderPlot({
ggplot(the, aes(x=get(input$xcol), ..count..*100/sum(..count..))) +
geom_bar(aes(fill = get(input$ycol)), position = "fill") +
geom_text(aes(label = scales::percent(..prop..),y= ..prop.. ),
stat= "count", vjust = -.5)
})
})
我想创建新列id 1 value1 2 value2 3 value3
1 ph 7 temp 44 cond 3
2 temp 45 cond 5 ph 5
3 temp 12 ph 5 cond 8
,ph
,temp
,alk
等,同时保持与该行中的列对应的每个值。预期的输出如下所示:
cond
答案 0 :(得分:1)
让我们尝试一下:
df1 = df.set_index('id')
df1.columns = ['Col'+i if i.isdigit() else i for i in df1.columns]
df2 = df1.reset_index()
pd.wide_to_long(df2, ['Col','value'],'id','num','','.+').reset_index(level=1, drop=True).set_index('Col', append=True)['value'].unstack()
输出:
Col cond ph temp
id
1 3 7 44
2 5 5 45
3 8 5 12
答案 1 :(得分:0)
C_DecryptEncryptUpdate
给出结果:
C_DecryptVerifyUpdate