【发布时间】:2019-10-07 03:03:31
【问题描述】:
。我想在 0.5 0.5 之间的数据框中进行过滤 并将两个过滤后的数据框合并为一个新的数据框。
- 有效吗?任何替代品也非常感谢
- 请注意,我的原始数据框比代码中给出的示例要大得多。
我希望输出是一个由 mean_depth 过滤的 3 列新数据框。
import pandas as pd
import numpy as np
data= {'x': [462574.63, 462617.91, 462614.76, 462621.02, 462624.16 ],
"Y": [5724781.1, 5724750.7, 5724745.7, 5724750.7, 5724755.7 ],
"depth": [32.75, 34.74, 35.30, 34.20, 33.73]}
df = pd.DataFrame(data)
df
#df.describe()
mean_depth = 34.144000
# filter to only show the rows in a 0.5 < mean_depth > 0.5 values
# Can this be automated? so that mean_depth not has to be inputed manualy?
【问题讨论】:
-
感谢您提供良好的示例数据。你能澄清
0.5 < mean > 0.5的意思吗?看起来你想要同时小于和大于相同值的数字,我想我只是误解了。 -
你能更清楚你的期望吗
-
您是指
mean_depth - 0.5和mean_depth + 0.5之间的值吗?
标签: python pandas dataframe filtering mean