I have a boolean subsetting function that works on a pandas dataframe:
def operational(df):
return df[(df['cf'] != 0) & (df['ta'] > 0)]
it works well in a script and in a jupiter notebook, when entered in cell:
#df = ...
df2 = operational(df)
However, if I keep function definiton in pick.py
and import in to jupyter, things go unexpected. It seems upon import of a module jupiter does not reconise the types of variables inside a function:
import pick
pick.operational(df).head()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-374442fd7c0a> in <module>()
1 import pick
----> 2 pick.operational(df).head()
C:\Users\Евгений\Documents\GitHub\sandbox\pick.py in operational(_df)
11
12 def operational(df):
---> 13 return df[(df['cf'] != 0) & (df['ta'] > 0)]
14
15
TypeError: 'method' object is not subscriptable
Is importing something to notebook a generally bad idea? I use jupiter lab, if that matters.