有两个df
df1和df2
df1:
21 | 20 | 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10
df2:
1 | 2 | 3 | 4 | 5
abc asdf df 132 248
ban cat ball bcd aisc
如何合并两个df,以便获得所需的输出
需要的输出:
21 | 20 | 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10
nan nan abc asdf df 132 248 nan nan nan
nan nan ban cat ball bcd aisc nan nan nan
答案 0 :(得分:0)
您可以通过concat(..)
[pandas-doc]来获取此信息:
# creating a deep learning model with keras
def build_model():
model = Sequential()
model.add(Dense(64, input_dim=4, activation='relu'))
model.add(Dense(32, activation='relu'))
model.add(Dense(16, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(Adam(lr=lr, decay=decay), loss='mse')
model.summary()
return model
model = build_model()
# running the game
for i_episodes in range(200):
env.reset()
for i in range(100):
env.render()
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
# observation = ndarray float64
# reward = float
# done = bool
# action = int
# info = empty
observation = np.asarray(observation)
reward = np.asarray(reward)
action = np.asarray(action)
model.fit(np.expand_dims(observation, axis=0), np.expand_dims(action, axis=0))
这将如文档所述:
使用可选的设置将熊猫对象沿着特定的轴连接起来 逻辑沿着其他轴。
还可以在串联上添加一层分层索引 轴,如果标签相同(或重叠),则可能会有用 在传递的轴号上。
它将因此对两个数据框的列名称进行“合并”,然后为对应列的两个数据框之一中缺少的列填充install.packages("lavaan")
install.packages ("semPlot")
install.packages ("semTools")
install.packages("psych")
install.packages("MVN")
install.packages("mvtnorm")
install.packages("ggplot2")
install.packages("qgraph")
install.packages("psych")
。
注意:列名显然不应多次出现。如果发生这种情况,那当然会出错,因为不清楚如何处理这种情况。
如果列名称在 empty 数据框中多次出现,则可以使用以下方法解决该问题:
ILI <- 'proto =~ ILproto_1 + ILproto_2 + ILproto_3 + ILproto_4
advance =~ ILadvance_1 + ILadvance_2 + ILadvance_3 + ILadvance_4
entre =~ ILentre_1 + ILentre_2 + ILentre_3 + ILentre_4
impres =~ ILimpres_1 + ILimpres_2 + ILimpres_3'
#fit the model
ILI.fit <- cfa(ILI, data=vdata_clean1, meanstructure = TRUE, std.lv = TRUE, estimator = "MLM")
parameterEstimates(ILI.fit,ci=FALSE, standardized= TRUE)
summary(ILI.fit,fit.measures = TRUE, standardized=T, rsquare=T)
#create picture:
semPaths(ILI.fit, whatLabels = "std", layout = "tree")
#plot path diagram:
semPaths(ILI.fit, title=FALSE,
curvePivot = TRUE)
#standardized parameters:
semPaths(ILI.fit, edge.label.cex=1.2, whatLabels ="std", layout = "tree", rotation = 2,
what = "std", edge.color = "Black", curvePivot = F, exoVar = T)
作为预处理步骤。