Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有没有一种方法可以;“覆盖”;在特定位置有两个(熊猫)数据帧?_Python_Pandas_Dataframe - Fatal编程技术网

Python 有没有一种方法可以;“覆盖”;在特定位置有两个(熊猫)数据帧?

Python 有没有一种方法可以;“覆盖”;在特定位置有两个(熊猫)数据帧?,python,pandas,dataframe,Python,Pandas,Dataframe,这是我的伪代码 source a b c d e 0 x x x x x 1 x x x x x 2 x x x x x 3 x x x x x 4 x x x x x 5 x x x x x 然后我有一个查找数据帧 lookup a b c 0 1 2 3 有没有类似这样的函数-pd.source.overlay(lookup[2,c])-在特定位置生成“overlay” a b c

这是我的伪代码

source

   a  b  c  d  e
0  x  x  x  x  x
1  x  x  x  x  x
2  x  x  x  x  x
3  x  x  x  x  x
4  x  x  x  x  x
5  x  x  x  x  x
然后我有一个查找数据帧

lookup

   a  b  c
0  1  2  3
有没有类似这样的函数-
pd.source.overlay(lookup[2,c])
-在特定位置生成“overlay”

   a  b  c  d  e
0  x  x  x  x  x
1  x  x  x  x  x
2  x  x  1  2  3
3  x  x  x  x  x
4  x  x  x  x  x
5  x  x  x  x  x

首先我们对索引进行ge,然后分配值

df.values[2,2:]=lu.values
df
   a  b  c  d  e
0  x  x  x  x  x
1  x  x  x  x  x
2  x  x  1  2  3
3  x  x  x  x  x
4  x  x  x  x  x
5  x  x  x  x  x

col='c'

df.values[2,df.columns.get_indexer([col])[0]:]=lu.values

首先我们对索引进行ge,然后分配值

df.values[2,2:]=lu.values
df
   a  b  c  d  e
0  x  x  x  x  x
1  x  x  x  x  x
2  x  x  1  2  3
3  x  x  x  x  x
4  x  x  x  x  x
5  x  x  x  x  x

col='c'

df.values[2,df.columns.get_indexer([col])[0]:]=lu.values
像这样:

In [898]: df.iloc[2, -3:] = lu.values

In [899]: df
Out[899]: 
   a  b  c  d  e
0  x  x  x  x  x
1  x  x  x  x  x
2  x  x  1  2  3
3  x  x  x  x  x
4  x  x  x  x  x
5  x  x  x  x  x
像这样:

In [898]: df.iloc[2, -3:] = lu.values

In [899]: df
Out[899]: 
   a  b  c  d  e
0  x  x  x  x  x
1  x  x  x  x  x
2  x  x  1  2  3
3  x  x  x  x  x
4  x  x  x  x  x
5  x  x  x  x  x

就这样?对于像我这样的新手来说,这是beautiful@Maxcot因为您分配的值与索引和列不匹配,所以我们需要执行值,删除索引,就像这样吗?对于像我这样的新手来说,这是beautiful@Maxcot由于您分配的值与索引和列不匹配,因此我们需要执行值,删除索引impact@Maxcot既然答案有帮助,请也投票表决。@Maxcot既然答案有帮助,请也投票表决。