'(simple) problem with changing type and key error in Pandas

DataFrame

x y num
0 0 7
1 0 8
1 1 9
1 2 10
def my_function(x,y):
    print(df["num"][(df["x"] == x) & (df["y"] == y + 1)])

x = my_function(1,1)
print(x)
print(type(x))

Out:
3    10
Name: num, dtype: int64
None
<class 'NoneType'>

I don't know why its becoming NoneType instead of pandas.series and how can i get "num" value here ("10")

x[0] gives key error :<



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source