Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventsEndpoint.search() takes 1 positional argument but 2 were given #71

Closed
MattNot opened this issue Feb 22, 2024 · 2 comments
Closed

Comments

@MattNot
Copy link

MattNot commented Feb 22, 2024

Following the https://github.com/predicthq/phq-data-science-docs/blob/master/attended-events/part_1_data_engineering.ipynb

I receive this error:
EventsEndpoint.search() takes 1 positional argument but 2 were given
When running the "Calling the PredictHQ API and Fetching Events" cell, any help?

@hhheath
Copy link

hhheath commented Feb 22, 2024

Hey @MattNot, I'll take a look at this today and follow back up with you. Thanks so much for finding this!

@hhheath
Copy link

hhheath commented Feb 22, 2024

@MattNot In the cell where you call the events API for the first time, you'll need to make two changes:

  1. you'll need to use **parameters in the function call to pass the unpacked dictionary to the function
  2. update event.to_dict() to event.model_dump()

The full cell should look like this:

results = []

# Iterating through all the events that match our criteria and adding them to our results
for event in phq.events.search(**parameters).iter_all():
    results.append(event.model_dump())

# Converting the results to a DataFrame
event_df = pd.DataFrame(results)

These were updates that we rolled out with our most recent update of the SDK. I'll make a PR with these updates! Thanks for raising this with us and feel free to reach out if you're still running into any issues! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants