我是熊猫和蟒蛇的新手。我想将一列从dataframe2插入到dataframe1中。但是,我的条件是,dataframe2中缺少某些行。因此,我只想将行键匹配的行和一些空值插入新列的其余行中。例如: DataFrameExamples
我的数据帧各有5万多行。请让我知道该怎么做。谢谢
答案 0 :(得分:4)
您可能正在寻找merge功能。左联接可以解决您的问题。默认情况下,合并使用内部联接。您可以通过传递不同的how参数来更改此行为:
"dependencies": {
"axios": "^0.18.0",
"mobx": "^5.8.0",
"mobx-react": "^5.4.3",
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-device-info": "^0.24.3",
"react-native-elements": "^1.0.0-beta5",
"react-native-haptic-feedback": "^1.3.0",
"react-native-svg": "^8.0.10",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^3.0.9",
"rollbar-react-native": "^0.4.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-decorators": "^7.2.3",
"babel-eslint": "^10.0.1",
"babel-jest": "23.6.0",
"eslint": "^5.12.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.12.3",
"eslint-plugin-react-native": "^3.5.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
}
答案 1 :(得分:0)
我不确定这是否可以完全解决,但是您可以尝试: df ['c2'] =一个新系列,为null。然后
对于Df1中的所有键(如果该键存在于df_2中),请使用相应的值更新该键在df1中的c2。