So I am using Polars DF and got a bit stuck in regards to a task I am trying to do.
So basically I have a df, lets call it auctiondf which can contain a lot of "auctions" I also have a trackingdf which contains items/auctions I want to track with specific search criterias.
In the trackingdf there will always be filled out an ItemId (Mandatory), the rest of the fields are however not mandatory to have been filled out.
If only the ItemId in the trackingDF is filled out, then I want to find all the auctions/items from auctionDF with that ItemId regardless of the other "columns"
If however any of the other fields has been filled out, those criterias has to be met as well, such as Realmname, Stat[x] and buyoutgold
There can be 5 stats from stat0 to stat4, I dont care about the order, so if possible it would be nice that the "search" doesn't care about the order either.
lets say ItemId has to be 15331 and I have put in +3 Stamina in Stat0 and +3 Agility in Stat1, then it's fine it finds results in AuctionDF where the ItemId is 15331 and Stat0 being +3 Agility and Stat 1 being +3 Stamina as long as the Stat[x] criteria is met.
auctionDF['Buyout'] of course cant exceed the amount in the trackingdf['buyoutgold'] column, however if it's blank the auctionDF['Buyout'] can be any amount
I hope the above makes sense and if you got any questions, please feel free to ask :)
import polars as pl
auctiondata = {"ItemId": [15331, 15332, 15333, 15213, 15331, 15213],
"AuctionId": [2084868458, 2085008809, 2087827052, 2087835700, 2087827999, 2087827997],
"RealmName": ['Gehennas', 'Gehennas', 'Mograine', 'Lakeshire', 'Gehennas', 'Bloodfang'],
"Stat0": ['+3 Stamina', '+2 Intelelct', '+3 Stamina', '+3 Agility', '+3 Stamina', '+3 Stamina'],
"Stat1": ['+3 Agility', '+3 Stamina', '+3 Intellect', '+3 Stamina', '+3 Agility', '+3 Agility'],
"Stat2": ['', '', '', '','',''],
"Stat3": ['', '', '', '','',''],
"Stat4": ['', '', '', '','',''],
"buyoutgold": ['40', '', '', '', '120','']}
trackingdata = {"ItemId": [15331, 15213, 15333],
"RealmName": ['Gehennas', '', 'Mograine'],
"Stat0": ['+3 Stamina', '+3 Stamina', '+3 Stamina'],
"Stat1": ['+3 Agility', '+3 Agility', '+3 Intellect'],
"Stat2": ['', '', ''],
"Stat3": ['', '', ''],
"Stat4": ['', '', ''],
"buyoutgold": ['50', '', '']}
resultdata = {"ItemId": [15331, 15333, 15213, 15213],
"AuctionId": [2084868458, 2087827052, 2087835700, 2087827997],
"RealmName": ['Gehennas', 'Mograine', 'Lakeshire', 'Bloodfang'],
"Stat0": ['+3 Stamina', '+3 Stamina', '+3 Agility', '+3 Stamina'],
"Stat1": ['+3 Agility', '+3 Intellect', '+3 Stamina', '+3 Agility'],
"Stat2": ['', '', '', ''],
"Stat3": ['', '', '', ''],
"Stat4": ['', '', '', ''],
"buyoutgold": ['40', '', '', '']}
auctiondf = pl.DataFrame(auctiondata)
print(auctiondf)
trackingdf = pl.DataFrame(trackingdata)
print(trackingdf)
resultdf = pl.DataFrame(resultdata)
print(resultdf)