我已经用谷歌搜索了它,通常的解决方案似乎是,迭代器必须是常量。但我仍然得到这个错误。这是我的代码:
std::vector<std::vector<std::vector<std::string> > >::const_iterator itc;
std::vector<std::vector<std::string> >::const_iterator itb;
std::vector<std::string>::const_iterator ita;
for (ita = metadata.getTestVektor().begin(); ita != metadata.getTestVektor().end(); ++ita)
{
for (itb = ita->begin(); itb != ita->end(); ++itb)
{
for (itc = itb->begin(); itc != itb->end(); ++itc)
{
}
}
}
metadata.getTestVektor()返回3d vektor:
std::vector<std::vector<std::vector<std::string>>> testvektor;
日志:
/home/MetaDataCreator.cpp:20: error: no match for 'operator=' (operand types are 'std::vector<std::basic_string<char> >::const_iterator {aka __gnu_cxx::__normal_iterator<const std::basic_string<char>*, std::vector<std::basic_string<char> > >}' and 'std::vector<std::vector<std::vector<std::basic_string<char> > > >::iterator {aka __gnu_cxx::__normal_iterator<std::vector<std::vector<std::basic_string<char> > >*, std::vector<std::vector<std::vector<std::basic_string<char> > > > >}')
for (ita = metadata.getTestVektor().begin(); ita != metadata.getTestVektor().end(); ++ita)
^
^点在“=”符号
答案 0 :(得分:1)
好像你已经混淆了In [91]:
merged = pd.merge(df1,df2,indicator=True, how='left' )
merged
Out[91]:
RecorderID GroupID Location SomeColumn _merge
0 CT-1000001 BV- Cape Town SomeValue left_only
1 CT-1000002 MP- Johannesburg SomeValue left_only
2 CT-1000003 BV- Durban SomeValue both
In [92]:
merged[merged['_merge'] == 'left_only']
Out[92]:
RecorderID GroupID Location SomeColumn _merge
0 CT-1000001 BV- Cape Town SomeValue left_only
1 CT-1000002 MP- Johannesburg SomeValue left_only
和ita
,其中itc
具有最里面的迭代器类型。
但也要考虑Joachim所说的内容 - 如果ita
按值返回,则在两个不同的向量上调用getTestVektor()
和begin()
。不好!</ p>