对于Python中的数据框(请参见下文),我想使用S元素所属的G组的均值和标准偏差来计算S的z得分。属于G的g组,
function removeSpecialCharacters(metadata) {
return metadata.map(datum =>
({ ...datum, id: datum.id.replace(/[.|&;$%@%"<>+]/g, '') })
)
}
const data = [{id: "somethin%g", apple: "dfgdf efd"}];
console.log(removeSpecialCharacters(data));
最优雅的方法是什么?
s_z = (s - mu(g))/sigma(g).
答案 0 :(得分:2)
我认为您需要具有lambda函数的import java.util.concurrent.TimeUnit;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Shape;
import javafx.stage.Stage;
public class SquareThreads extends Application {
@Override
public void start(Stage primaryStage) {
Pane pane = new Pane(); //container for shapes
MakeRectangles mr = new MakeRectangles (); //make new shapes on other thread
mr.getShapes().addListener((ListChangeListener<Shape>) change -> { //respond to shapes added
while (change.next()) {
//if items are removed
for (Shape s : change.getRemoved()) {
Platform.runLater(()-> pane.getChildren().remove(s));
}
//if items are added
for (Shape s : change.getAddedSubList()) {
Platform.runLater(()-> pane.getChildren().add(s));
}
}
});
Scene scene = new Scene(pane,600,600);
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.sizeToScene();
mr.start(); //start making new rectangles
}
public static void main(String[] args) {
launch(args);
}
}
class MakeRectangles implements Runnable {
//store the shapes created in an observable list
private final ObservableList<Shape> shapes;
private boolean cancel;
private final Thread t;
public MakeRectangles() {
shapes = FXCollections.observableArrayList();
t= new Thread(this);
}
@Override
public void run(){
cancel = false;
while (! cancel){
Rectangle rect = new Rectangle((int) (Math.random() * 600), (int) (Math.random() * 600),100,100);
rect.setFill(Color.color(Math.random(), Math.random(), Math.random()));
shapes.add(rect);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ex) { ex.printStackTrace(); }
}
}
ObservableList<Shape> getShapes(){
return shapes;
}
void start(){
stop(); //stop previous run if any
t.start();
}
void stop(){
cancel = true;
try {
t.join(); //wait for completion
} catch (InterruptedException ex) { ex.printStackTrace(); }
}
}
-带有groupby
和mean
或通过scipy.stats.zscore
,只需更改默认值std
:
ddof