Get a dataframe from the named data source from preswald.toml If the source is a database/has multiple tables, you must specify a table_name
(source_name: str, table_name: str | None = None)
| 37 | |
| 38 | |
| 39 | def get_df(source_name: str, table_name: str | None = None) -> pd.DataFrame: |
| 40 | """ |
| 41 | Get a dataframe from the named data source from preswald.toml |
| 42 | If the source is a database/has multiple tables, you must specify a table_name |
| 43 | """ |
| 44 | try: |
| 45 | service = PreswaldService.get_instance() |
| 46 | df_result = service.data_manager.get_df(source_name, table_name) |
| 47 | logger.info(f"Successfully got a dataframe from data source: {source_name}") |
| 48 | return df_result |
| 49 | except Exception as e: |
| 50 | logger.error(f"Error getting a dataframe from data source: {e}") |