我有一个数据框,如下所示:
from uncertainties import ufloat # pip3 uncertainties.py
import random
random.seed(0)
values = [[round(random.random(),2) for i in range(3)] for j in range(4)]
df = pd.DataFrame(values, index=['name1','sd', 'name2', 'sd'], columns=['A','B','C'])
我想重新排列数据,将均值和sd合并为ufloat的一行,其预期输出如下:
new_values = [[ufloat(0.91,0.90), ufloat(0.98,0.31), ufloat(0.81,0.73)],
[ufloat(0.90,0.10), ufloat(0.68,0.43), ufloat(0.47, 0.61)]]
df = pd.DataFrame(new_values, index=['name1', 'name2'], columns=['A','B','C'])
我认为创建两个数据框并以某种方式将它们组合起来最简单
mean = df.iloc[::2].reset_index()
std = df.iloc[1::2].reset_index()
现在我需要将两者合并并应用ufloat
答案 0 :(得分:0)
这是我当前的解决方案:
auto it = std::find_if(sourceEmployee.begin(), sourceEmployee.end(),
[&sourceEmployee, id](const auto &obj) { return obj->getID() == id; });
auto index = std::distance(sourceEmployee.begin(), it);
switch(sourceEmployee[index]->getStatus()) { // returning status
case Intern::Status::Intern: // does it recognize object properly?
auto tmp0 = std::move(*it);
(*it).reset(); // ??
*it = std::make_shared<Worker>(tmp0);
cout << "Employee " << id << " has been promoted" << endl;
break;