« first day (45 days earlier)      last day (55 days later) » 

1:07 PM
Hi @SOK Can you show me the line of code which you have tried and is throwing the error?
 
SOK
i put generic data on the question but here is my specific line:
allcombined['ProjectionsDifference'] = allcombined['PropTarget'] - allcombined.LookupMarket(allcombined.index, allcombined['LookupMarket'].map({'Pass.Yds': 'Pass.Yds',
'Pass.Cmp': 'Pass.Cmp' }))
 
Can you please format while pasting?
Just select the code and press CTRL +K
 
SOK
ah sorry just realised my erroer!
allcombined['ProjectionsDifference'] = allcombined['PropTarget'] - allcombined.lookup(allcombined.index, allcombined['LookupMarket'].map({'Pass.Yds': 'Pass.Yds',
'Pass.Cmp': 'Pass.Cmp' }))
 
@SOK No problem :).. Now working fine?
 
SOK
error*. That seemed to work now. I had changed df.lookup to my column which is named LookupMarket
 
1:11 PM
Ahhh...That's why throwing the error..
 
SOK
yes perfect - thanks heaps for that!
 
glad i could be of help, happy coding :)
@SOK If possible can you please either delete the last comment or leave another comment explaining the error was due to typo...It would be helpful for the future readers..
 
SOK
sure can
 
Thanks :)
 
SOK
is there a way with the .map function to "catch all" eg if there is a value that you dont have a definition for (useless)
@ShubhamSharma
 
1:24 PM
@SOK in that case the value after mapping will be NaN
and it will not work with lookup...
 
SOK
can i map a value to a nan eg {'k':"nan"} instead of a column name
?
because for k there is no column for that
 
So in that case How you are planning to subtract NaN from the Value column?
 
SOK
yeah maybe best to delete the rows where k exist
 
yes that's the best possible solution.
Hey @SOK
You can try this:
dct = {'a': 'Col a', 'b': 'Col b', 'c': 'Col c'}
s = df['Category'].map(dct).dropna()
df['Calc'] = df.loc[s.index, 'Value'] - df.lookup(s.index, s)
 
SOK
1:43 PM
thanks ill give it a go
 
2:01 PM
Sure :)
 

« first day (45 days earlier)      last day (55 days later) »