class_docstr: Strava List Club Activities by id Table implementation
class_docstr_tok: ["Strava","List","Club","Activities","by","id","Table","implementation"]
docstr: Pulls data from the Strava  "List Club Activities " API endpoint
  Parameters
  ----------
  query : ast.Select
     Given SQL SELECT query
  Returns
  -------
  pd.DataFrame
      strava "List Club Activities" matching the query
  Raises
  ------
  ValueError
      If the query contains an unsupported condition
docstr_tok: ["Pulls","data","from","the","Strava","``","List","Club","Activities","``","API","endpoint","Parameters","--","--","--","--","--","query",":","ast.Select","Given","SQL","SELECT","query","Returns","--","--","--","-","pd.DataFrame","strava","``","List","Club","Activities","''","matching","the","query","Raises","--","--","--","ValueError","If","the","query","contains","an","unsupported","condition"]
code: def select(self, query: ast.Select) -> pd.DataFrame:
      """Pulls data from the Strava  "List Club Activities " API endpoint
      Parameters
      ----------
      query : ast.Select
         Given SQL SELECT query
      Returns
      -------
      pd.DataFrame
          strava "List Club Activities" matching the query
      Raises
      ------
      ValueError
          If the query contains an unsupported condition
      """
      conditions = extract_comparison_conditions(query.where)
  
      order_by_conditions = {}
      clubs_kwargs = {}
  
      if query.order_by and len(query.order_by) > 0:
          order_by_conditions["columns"] = []
          order_by_conditions["ascending"] = []
  
          for an_order in query.order_by:
              if an_order.field.parts[0] != "id":
                  next
              if an_order.field.parts[1] in self.get_columns():
                  order_by_conditions["columns"].append(
                      an_order.field.parts[1]
                  )
  
                  if an_order.direction == "ASC":
                      order_by_conditions["ascending"].append(True)
                  else:
                      order_by_conditions["ascending"].append(False)
              else:
                  raise ValueError(
                      f"Order by unknown column {an_order.field.parts[1]}"
                  )
  
      for a_where in conditions:
          if a_where[1] == "strava_club_id":
              if a_where[0] != "=":
                  raise ValueError(
                      "Unsupported where operation for strava_club_id "
                  )
              clubs_kwargs["type"] = a_where[2]
          else:
              raise ValueError(
                  f"Unsupported where argument {a_where[1]}"
              )
  
      strava_club_activities_df = self.call_strava_clubactivities_api(
          a_where[2]
      )
  
      selected_columns = []
      for target in query.targets:
          if isinstance(target, ast.Star):
              selected_columns = self.get_columns()
              break
          elif isinstance(target, ast.Identifier):
              selected_columns.append(target.parts[-1])
          else:
              raise ValueError(f"Unknown query target {type(target)}")
  
      if len(strava_club_activities_df) == 0:
          strava_club_activities_df = pd.DataFrame(
              [], columns=selected_columns
          )
      else:
          strava_club_activities_df.columns = self.get_columns()
          for col in set(strava_club_activities_df.columns).difference(
              set(selected_columns)
          ):
              strava_club_activities_df = (
                  strava_club_activities_df.drop(col, axis=1)
              )
  
          if len(order_by_conditions.get("columns", [])) > 0:
              strava_club_activities_df = (
                  strava_club_activities_df.sort_values(
                      by=order_by_conditions["columns"],
                      ascending=order_by_conditions["ascending"],
                  )
              )
  
      if query.limit:
          strava_club_activities_df = strava_club_activities_df.head(
              query.limit.value
          )
  
      return strava_club_activities_df
  
file_path: mindsdb/mindsdb/integrations/handlers/strava_handler/strava_tables.py
imports: import pandas
  from typing import List
  from mindsdb.integrations.libs.api_handler import APITable
  from mindsdb.integrations.utilities.sql_utils import extract_comparison_conditions
  from mindsdb.utilities import log
  from mindsdb_sql.parser import ast
  import requests
  import pandas
  import json
label_desc: Use image node_id 1 for calling the StravaClubActivitesTable obj's underlying member method code with example usage: obj.select(query) and returns: strava_club_activities_df