我有一个看起来像
的数据框const JwtStrategy = require("passport-jwt").Strategy;
const ExtractJwt = require("passport-jwt").ExtractJwt;
const mongoose = require("mongoose");
const Student = mongoose.model("students");
const Admin = mongoose.model("admins");
const keys = require("../config/keys");
const opts = {};
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
opts.secretOrKey = keys.secretOrKey;
module.exports = passport => {
passport.use(
new JwtStrategy(opts, (jwt_payload, done) => {
Student.findById(jwt_payload.id).then(student => {
if (!student) {
Admin.findOne(jwt_payload.id).then(admin => {
if (!admin) {
return done(null, false);
}
return done(null, admin);
});
}
return done(null, student);
});
})
);
};
现在,我想用相同的Name Value
Car1 Station
Car1 NA
Car1 NA
Car1 Station
Car2 Hatchback
Car2 NA
变量的非NA值填充NA
列中的Value
值。因此,结果数据框应类似于
Name
有人知道如何做到这一点而不遍历整个数据帧吗?