I am trying to make a code that classify data in data frame based on depth so as to make formation types at each depth
data frame has depth column and has hole size
based on hole size and column of depth we can get the formation at each depth , i write the code as following
for i in df4.index:
#creat the variables to be used as operation definer
depth = df2.at[i, "DEPTH"]
size = df2.at[i , "Hole_size"]
if depth < 1710 and size == 17.5 :
df4.at[i,"Formation"] = "MOGHRA"
elif hole_size == 17.5 and hole_depth >= 1710 and hole_depth < 4375 :
df2.at[i,"Formation"] = "DABAA"
elif hole_size == 17.5 and hole_depth >= 4375 and hole_depth < 4422 :
df2.at[i,"Formation"] = "APPOLONIA"
elif hole_size == 12.25 and hole_depth >= 4422 and hole_depth < 7010 :
df2.at[i,"Formation"] = "APPOLONIA"
elif hole_size == 12.25 and hole_depth >= 7010 and hole_depth < 10758 :
df2.at[i,"Formation"] = "KHOMAN"
elif hole_size == 12.25 and hole_depth >= 10758 and hole_depth < 11794 :
df2.at[i,"Formation"] = "A/R A"
elif hole_size == 12.25 and hole_depth >= 11794 and hole_depth < 11807 :
df2.at[i,"Formation"] = "A/R B"
elif hole_size == 8.5 and hole_depth >= 11807 and hole_depth < 13335 :
df2.at[i,"Formation"] = "A/R B"
elif hole_size == 8.5 and hole_depth >= 13335 and hole_depth < 13698 :
df2.at[i,"Formation"] = "A/R C"
elif hole_size == 8.5 and hole_depth >= 13698 and hole_depth < 14282 :
df2.at[i,"Formation"] = "A/R D"
elif hole_size == 8.5 and hole_depth >= 14282 and hole_depth < 15050 :
df2.at[i,"Formation"] = "A/R E"
elif hole_size == 8.5 and hole_depth >= 15050 and hole_depth < 15250 :
df2.at[i,"Formation"] = "A/R F"
elif hole_size == 8.5 and hole_depth >= 15250 and hole_depth <= 16000 :
df2.at[i,"Formation"] = "A/R G"
else :
df4.at[i,"Formation"] = "OTHER"
shows the results
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-30-93d82d7d92e8> in <module>
3 depth = df2.at[i, "DEPTH"]
4 size = df2.at[i , "Hole_size"]
----> 5 if depth < 1710 and size == 17.5 :
6 df4.at[i,"Formation"] = "MOGHRA"
7 ''''
~\anaconda3\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
1535 @final
1536 def __nonzero__(self):
-> 1537 raise ValueError(
1538 f"The truth value of a {type(self).__name__} is ambiguous. "
1539 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
want to find the error