I'm importing this csv file with pandas:
Date Type Price1 Price2 Price3 LowestBuy HighestSell
01-02-19 BUY 0.1201 0.1202 0.1205
01-02-19 SELL 0.1198 0.1199 0.1202
Now I want to add the minimum of the colums Price1, Price2, Price3 to the LowestBuy column if the type (column 2) of that row is equal to BUY. When the type is SELL I want to add the maximum of the colums Price1, Price2, Price3 to the HighestSell column. Is this possible?
This is my code so far:
import pandas as pd
path = "orderbookData/NEOBTC2019-02-02.csv"
df = pd.read_csv(path, na_values=0)
for row in df:
if(df["type"] == "BUY"):
df["lowestBuy"] = df[["Price1", "Price2", "Price3"]].min(axis=1)
if(df["type"] == "SELL"):
df["highestSell"] = df[["Price1", "Price2", "Price3"]].max(axis=1)
print(df)
When I run this code I get this error message:
Exception has occurred: ValueError
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
File "D:\test.py", line 10, in <module>
if(df["type"] == "BUY"):