multi-level

Pandas reshape dataframe by adding a column level based on the value of another column [duplicate]

若如初见. 提交于 2020-01-14 14:33:10
问题 This question already has answers here : How to pivot a dataframe (2 answers) Closed 9 months ago . I have a pandas dataframe and I would like to add a column level to split specific columns ( metric_a , metric_b , metric_c ) into several subcolumns based on the value of another column ( parameter ). Current data format: participant param metric_a metric_b metric_c 0 alice a 0,700 0,912 0,341 1 alice b 0,736 0,230 0,370 2 bob a 0,886 0,364 0,995 3 bob b 0,510 0,704 0,990 4 charlie a 0,173 0

Imputation using mice with clustered data

 ̄綄美尐妖づ 提交于 2020-01-12 08:28:08
问题 So I am using the mice package to impute missing data. I'm new to imputation so I've got to a point but have run into a steep learning curve. To give a toy example: library(mice) # Using nhanes dataset as example df1 <- mice(nhanes, m=10) So as you can see I imputed df1 10 times using mostly default settings - and I am comfortable using this result in regression models, pooling results etc. However in my real life data, I have survey data from different countries. And so levels of missings

Returning subset of each group from a pandas groupby object

半城伤御伤魂 提交于 2019-12-24 15:00:27
问题 I have the multilevel dataframe that looks like: date_time name note value list index 1 0 2015-05-22 05:37:59 Tom 129 False 1 2015-05-22 05:38:59 Tom 0 True 2 2015-05-22 05:39:59 Tom 0 False 3 2015-05-22 05:40:59 Tom 45 True 2 4 2015-05-22 05:37:59 Kate 129 True 5 2015-05-22 05:41:59 Kate 0 False 5 2015-05-22 05:37:59 Kate 0 True I want iterate over the list , and for each first row of list check the value of column value , and if it is False , delete this row. So the final goal is to delete

reStructuredText Multilevel

不打扰是莪最后的温柔 提交于 2019-12-24 06:41:04
问题 How can I get such a structur with reStructuredText? Is it even possible? 1. Title 1.1 Subtitle 1.1.2 SubSubtitle 1.1.2.1 SubSubtitle 1.2 2ndSubtitle 1.2.1 2ndSubSubtitle 回答1: Did you look at the Sphinx documentation for nested lists? Your question should show that you made some effort, including what documentation you read, what you tried, what you expected, and what you observed. Nested lists are possible, but be aware that they must be separated from the parent list items by blank lines: *

Multi-level regression model on multiply imputed data set in R (Amelia, zelig, lme4)

不想你离开。 提交于 2019-12-22 05:25:22
问题 I am trying to run a multi-level model on multiply imputed data (created with Amelia); the sample is based on a clustered sample with group = 24, N= 150. library("ZeligMultilevel") ML.model.0 <- zelig(dv~1 + tag(1|group), model="ls.mixed", data=a.out$imputations) summary(ML.model.0) This code produces the following error code: Error in object[[1]]$result$call : $ operator not defined for this S4 class If I run a OLS regression, it works: model.0 <- zelig(dv~1, model="ls", data=a.out

Between/within standard deviations

你。 提交于 2019-12-18 16:54:30
问题 When working on a hierarchical/multilevel/panel dataset, it may be very useful to adopt a package which returns the within- and between-group standard deviations of the available variables. This is something that with the following data in Stata can be easily done through the command xtsum, i(momid) I made a research, but I cannot find any R package which can do that.. edit: Just to fix ideas, an example of hierarchical dataset could be this: son_id mom_id hispanic mom_smoke son_birthweigth 1

How to use nested problems in OpenMDAO 1.x?

Deadly 提交于 2019-12-17 09:59:10
问题 I am trying to implement Collaborative Optimization & other multi-level architectures on OpenMDAO. I read here that this can be done by defining a separate solve_nonlinear method in the Subclass of Problem. The issue is that while running the problem instance the defined solve_linear is not being called. Here is the code - from __future__ import print_function, division import numpy as np import time from openmdao.api import Component,Group, IndepVarComp, ExecComp,\ Problem, ScipyOptimizer,

overriding abstract methods in an inherited abstract class

左心房为你撑大大i 提交于 2019-12-14 00:20:59
问题 Okay so basically I have the following problem: I'm trying to have an abstract class inherit another abstract class that has an abstract method, but I don't want to implement the abstract method in either of them because a third class inherits from both of them: public abstract class Command { public abstract object execute(); } public abstract class Binary : Command { public abstract object execute(); //the issue is here } public class Multiply : Binary { public override object execute() { /

accessing Multi level xml with perl XML::Simple

断了今生、忘了曾经 提交于 2019-12-13 18:23:26
问题 All, I have read manyother other posts and have not been able to quite get a handle on this. I am pulling data form a web service and i am returned the following XML: $VAR1 = { 'error' => 'EndOfResults', 'model-responses' => { 'model' => [ { 'attribute' => { 'content' => 'wltvbswfc02', 'id' => '0x1006e' }, 'mh' => '0x100540' }, { 'attribute' => { 'content' => 'wltvsutm1ds02', 'id' => '0x1006e' }, 'mh' => '0x100c80' }, { 'attribute' => { 'content' => 'wltvsdora03', 'id' => '0x1006e' }, 'mh' =>

converting string IDs into numbers in a multilevel analysis using R

[亡魂溺海] 提交于 2019-12-12 23:03:00
问题 I have two data sets, one for student level data and another one for class level data. Student and class level IDs are generated as string values like: Student data set: student ID -> 141PSDM2L,1420CHY1L,1JNLV36HH,1MNSBXUST,2K7EVS7X6,2N2SC26HL,... class ID -> XK37HDN,XK37HDN,XK37HDN,3K3EH77,3K3EH77,2K36HN6,... class level data set: class ID -> XK37HDN,3K3EH77,2K36HN6,3K3LHSH,3K3LHSY,DK3EH14,DK3EH1H,DK3EH1K,... In student data set,each class ID is repeated equal to the number of students in