I'm working with some data, and just writing lines in sequence works fine and gives me the results I want (to extract a row of data from the date from the dataframe 'restaurant'):
orders = restaurant[(restaurant.index == date)]
However, when I put this into a function, it no longer is able to look it up by date, and instead just gives me a blank data frame:
def datesearch(date)
orders = restaurant[(restaurant.index == date)]
return orders
I can't seem to figure out why it's fine outside the function, but for some reason, it can't search by the date when I put it in a function.
I think restaurant is a global variable, so it might not be using the correct data. Try this:
def datesearch(date)
global restaurant
orders = restaurant[(restaurant.index == date)]
return orders
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With