我想将一个数据帧的选定列值分配给另一个数据帧。在
data = [['Math',87],['Geography',93],['Physics',72],['Geometry',75],['Astronomy',81],['English',94],['History',84]]
df = pd.DataFrame(data,columns=['Subjects','Grade'])
df
Subjects Grade
Math 87
Geography 93
Physics 72
Geometry 75
Astronomy 81
English 94
History 84
我有另一个数据帧:
^{pr2}$如何将坡率列值作为新列元素自动分配给df2?我希望得到:
Subjects_selected Retrieved_Values
Astronomy 81
Geography 93
Geometry 75
History 84
既然您提到了select,我将使用
isin
,这是'更像select'通过^{} 创建的
Series
使用{a1},并选择列Grade
:另一个带有^{} 和重命名列的解决方案:
^{pr2}$相关问题 更多 >
编程相关推荐