| 265 | * Format DataFrame for display |
| 266 | */ |
| 267 | export function formatDataFrame(dfInfoStr: string): { |
| 268 | shape: [number, number]; |
| 269 | columns: string[]; |
| 270 | dtypes: Record<string, string>; |
| 271 | preview: any[][]; |
| 272 | memory_usage?: number; |
| 273 | } { |
| 274 | try { |
| 275 | return JSON.parse(dfInfoStr); |
| 276 | } catch (error) { |
| 277 | console.error('[Python] Failed to parse DataFrame info:', error); |
| 278 | return { |
| 279 | shape: [0, 0], |
| 280 | columns: [], |
| 281 | dtypes: {}, |
| 282 | preview: [], |
| 283 | }; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Check if code contains plotting commands |