使用pandas从以下数据中获取值。
p1 p2 p3
ABC yes no yes
DEF yes no no
ghi no no no
正确的方法是使用pandas库
答案 0 :(得分:1)
我认为您正在寻找#include <algorithm>
#include <iostream>
#include <vector>
int main()
{
std::cout << "Please enter 3 values" << '\n';
std::vector<int> values;
for (int i = 0; i < 3; ++i)
{
int value;
std::cin >> value;
values.push_back(value);
}
std::sort(values.begin(), values.end());
std::cout << values[0] << ", " << values[1] << ", " << values[2] << '\n';
return 0;
}
,即如果您有数据框
.loc
p1 p2 ABC yes no EFG no no GHI no no
import pandas as pd
df = pd.DataFrame({'p1':['yes','no','no'],'p2':['no','no','no']},index=['ABC','EFG','GHI'])
输出:df.loc['GHI','p2']