我有一个很大的数据框,希望根据另一列(不是索引)的值来更改特定行中一列的值。
我可以针对单个实例执行此操作,我希望能够针对一定范围的值进行操作。
import pandas as pd
INDEX = list(range(1, 11))
LOCATIONS = [3, 10, 6, 2, 9, 1, 7, 5, 8, 4]
DATA = [294, 143, 385, 110, 281, 157, 188, 501, 135, 186]
# Make dataframe
DF = pd.DataFrame(LOCATIONS, columns=['locStuff'], index = INDEX)
DF['data'] = pd.Series(DATA, index=INDEX)
# Location and new value inputs
LOC_TO_CHANGE = 8
NEW_LOC_VALUE = 9
# Changing the value in the dataframe
LOC_IND_TO_ADJUST = DF.index[DF['locStuff'] == LOC_TO_CHANGE].tolist()
LOC_IND_TO_ADJUST_INT = LOC_IND_TO_ADJUST[0]
DF.iloc[LOC_IND_TO_ADJUST_INT -1, 1] = ('%03d' % NEW_LOC_VALUE)
我想输入locStuff [3:6] =来自另一个列表的数据,该列表的长度与间隔3:6相同。我希望更改locStuff列中的位置的dataframe'data'列的内容。
答案 0 :(得分:1)
我相信您需要:
var filterStageA = PipelineStageDefinitionBuilder.Match(someFilterA);
var filterStageB = PipelineStageDefinitionBuilder.Match(someFilterB);
var filterPepilineA = PipelineDefinition<Entity, Entity>.Create(new IPipelineStageDefinition[] { filterStageA });
var filterPepilineB = PipelineDefinition<Entity, Entity>.Create(new IPipelineStageDefinition[] { filterStageB });
var filterFacetA = AggregateFacet.Create("A_Result", filterPepilineA );
var filterFacetB = AggregateFacet.Create("B_Result", filterPepilineB );
var res = collection.Aggregate().Facet(filterFacetA , filterFacetB );