我有一个包含 11 列的数据框,我想根据其中两列中的值创建一个新的 0,1 列。
我已经尝试使用 np.where 创建其他列,但它不适用于这一列。
train["location"] = np.where(3750901.5068 <= train["x"] <= 3770901.5068
and -19268905.6133 <= train['y'] <= -19208905.6133, 1, 0)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:ValueError:系列的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。
我需要帮助才能将一个未知整数分成给定数量的偶数部分——或者至少尽可能均匀。各部分之和应为原始值,但各部分应为整数,且应尽可能接近。
Parameters
num: Integer - The number that should be split into equal parts
parts: Integer - The number of parts that the number should be split
into
Return Value
List (of Integers) - A list of parts, with each index representing the part and the number contained within it representing the size of the part. The parts will be ordered from smallest to largest.
Run Code Online (Sandbox Code Playgroud)
这就是我所拥有的
Parameters
num: Integer - The number that should be split into equal parts
parts: …
Run Code Online (Sandbox Code Playgroud)