如何根据大熊猫中的列条件删除行?

时间:2020-09-28 17:32:56

标签: python pandas keyerror

  • 我正在尝试删除#include <cstring> #include <iostream> #include <cmath> using namespace std; int main() { setlocale(LC_ALL, "rus"); int in, iz, k, s = 0, p; char str[255]; cout << "Enter the number system from which you want to translate" << endl; cin >> iz; cout << "Enter the number system to which we will translate" << endl; cin >> in; cout << "Enter the number" << endl; cin >> str; p = strlen(str) - 1; for (int i = 0; i < str[i]; i++) { switch (str[i]) { case 'a': k = 10; break; case 'b': k = 11; break; case 'c': k = 12; break; case 'd': k = 13; break; case 'e': k = 14; break; case 'f': k = 15; break; case '1': k = 1; break; case '2': k = 2; break; case '3': k = 3; break; case '4': k = 4; break; case '5': k = 5; break; case '6': k = 6; break; case '7': k = 7; break; case '8': k = 8; break; case '9': k = 9; break; case '0': k = 0; break; } s = s + k * pow(iz, p); p--; } char result[255]; _itoa_s(s, result, in); cout << "The result of a translation from a radix " << iz << " to radix " << in << " = " << result; return 0; } 列中包含'CENTER'的行。

作品:

2

输出效果:

BuildingNameContains_center = dframe[dframe[2].str.contains('CENTER')]

产生错误:

BuildingNameContains_center

dframe.drop(BuildingNameContains_center, inplace= True)

1 个答案:

答案 0 :(得分:2)

IIUC,而不是子集数据帧,然后尝试删除行。只需将您原始选择的倒数子集即可。

dframe = dframe.loc[~dframe[2].str.contains('CENTER'), :]