Pingul commited on
Commit
ab6bdb7
·
verified ·
1 Parent(s): 531d801

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -205,24 +205,18 @@ async def get_kepler_exoplanets(
205
  )
206
 
207
 
208
- @app.get("/kepler/{kepoi_name}", response_model=ExoplanetCumulative)
209
- async def get_cumulative_exoplanet_by_name(kepoi_name: str):
210
  """
211
- Obtiene un exoplaneta específico del dataset Cumulative por su nombre KOI.
212
-
213
- Ejemplo: K00001.01, K00002.01, etc.
214
  """
215
  df = load_csv_dataset("cumulative_2025.10.05_10.28.27.csv")
216
-
217
- # Buscar por kepoi_name
218
- exoplanet = df[df['kepoi_name'] == kepoi_name]
219
-
220
  if len(exoplanet) == 0:
221
- raise HTTPException(404, f"Exoplanet with kepoi_name '{kepoi_name}' not found")
222
-
223
- # Convertir a diccionario
224
  data = exoplanet.iloc[0].where(pd.notna(exoplanet.iloc[0]), None).to_dict()
225
-
226
  return ExoplanetCumulative(**data)
227
 
228
 
 
205
  )
206
 
207
 
208
+ @app.get("/kepler/{id}", response_model=ExoplanetCumulative)
209
+ async def get_cumulative_exoplanet_by_id(id: str):
210
  """
211
+ Obtiene un exoplaneta específico del dataset Cumulative por su nombre KOI o nombre Kepler.
212
+ Ejemplo: K00001.01, K00002.01, Kepler-227 b, etc.
 
213
  """
214
  df = load_csv_dataset("cumulative_2025.10.05_10.28.27.csv")
215
+ # Buscar por kepoi_name o kepler_name
216
+ exoplanet = df[(df['kepoi_name'] == id) | (df['kepler_name'] == id)]
 
 
217
  if len(exoplanet) == 0:
218
+ raise HTTPException(404, f"Exoplanet with kepoi_name or kepler_name '{id}' not found")
 
 
219
  data = exoplanet.iloc[0].where(pd.notna(exoplanet.iloc[0]), None).to_dict()
 
220
  return ExoplanetCumulative(**data)
221
 
222