You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"code": "from typing import List, Dict, Tuple\nimport statistics\n\n@node_entry\ndef calculate_statistics(data: List[Dict]) -> Tuple[Dict, int, str]:\n if not data:\n return {}, 0, \"No data provided\"\n \n stats = {}\n total_records = len(data)\n \n # Get numeric columns\n numeric_cols = []\n sample_record = data[0]\n for key, value in sample_record.items():\n if isinstance(value, (int, float)) and key != 'id':\n numeric_cols.append(key)\n \n # Calculate statistics for numeric columns\n for col in numeric_cols:\n values = [record[col] for record in data if isinstance(record[col], (int, float))]\n if values:\n stats[f\"{col}_mean\"] = round(statistics.mean(values), 2)\n stats[f\"{col}_median\"] = round(statistics.median(values), 2)\n stats[f\"{col}_min\"] = min(values)\n stats[f\"{col}_max\"] = max(values)\n if len(values) > 1:\n stats[f\"{col}_stdev\"] = round(statistics.stdev(values), 2)\n \n # Get categorical columns for summary\n categorical_summary = \"\"\n for key, value in sample_record.items():\n if isinstance(value, str) and key not in ['id', 'date']:\n unique_values = set(record[key] for record in data)\n categorical_summary += f\"{key}: {len(unique_values)} unique values; \"\n \n print(\"\\n=== STATISTICAL ANALYSIS ===\")\n print(f\"Total records: {total_records}\")\n for key, value in stats.items():\n print(f\"{key}: {value}\")\n if categorical_summary:\n print(f\"Categorical data: {categorical_summary}\")\n \n return stats, total_records, categorical_summary",
26
+
"gui_code": "",
27
+
"gui_get_values_code": "",
28
+
"gui_state": {},
29
+
"colors": {
30
+
"title": "#28a745",
31
+
"body": "#1e7e34"
32
+
}
33
+
},
34
+
{
35
+
"uuid": "trend-analyzer",
36
+
"title": "Trend Analyzer",
37
+
"pos": [450, 400],
38
+
"size": [300, 200],
39
+
"code": "from typing import List, Dict, Tuple\nfrom collections import Counter\n\n@node_entry\ndef analyze_trends(data: List[Dict]) -> Tuple[Dict, Dict, str]:\n if not data:\n return {}, {}, \"No data to analyze\"\n \n trends = {}\n patterns = {}\n \n # Date-based trends (if date field exists)\n if 'date' in data[0]:\n monthly_counts = Counter()\n for record in data:\n if 'date' in record:\n month = record['date'][:7] # Extract YYYY-MM\n monthly_counts[month] += 1\n trends['monthly_distribution'] = dict(monthly_counts)\n \n # Categorical distributions\n for key, value in data[0].items():\n if isinstance(value, str) and key not in ['id', 'date']:\n distribution = Counter(record[key] for record in data)\n patterns[f\"{key}_distribution\"] = dict(distribution.most_common(5))\n \n # Correlation analysis for numeric fields\n numeric_fields = [k for k, v in data[0].items() \n if isinstance(v, (int, float)) and k != 'id']\n \n correlations = \"\"\n if len(numeric_fields) >= 2:\n # Simple correlation analysis\n field1, field2 = numeric_fields[0], numeric_fields[1]\n values1 = [record[field1] for record in data]\n values2 = [record[field2] for record in data]\n \n # Calculate basic correlation indicator\n avg1, avg2 = sum(values1)/len(values1), sum(values2)/len(values2)\n covariance = sum((x - avg1) * (y - avg2) for x, y in zip(values1, values2)) / len(values1)\n \n if covariance > 0:\n correlations = f\"Positive relationship between {field1} and {field2}\"\n elif covariance < 0:\n correlations = f\"Negative relationship between {field1} and {field2}\"\n else:\n correlations = f\"No clear relationship between {field1} and {field2}\"\n \n print(\"\\n=== TREND ANALYSIS ===\")\n print(f\"Trends: {trends}\")\n print(f\"Patterns: {patterns}\")\n print(f\"Correlations: {correlations}\")\n \n return trends, patterns, correlations",
40
+
"gui_code": "",
41
+
"gui_get_values_code": "",
42
+
"gui_state": {},
43
+
"colors": {
44
+
"title": "#fd7e14",
45
+
"body": "#e8590c"
46
+
}
47
+
},
48
+
{
49
+
"uuid": "dashboard-display",
50
+
"title": "Analytics Dashboard",
51
+
"pos": [850, 250],
52
+
"size": [400, 350],
53
+
"code": "from typing import Dict\n\n@node_entry\ndef create_dashboard(stats: Dict, record_count: int, categorical_info: str, trends: Dict, patterns: Dict, correlations: str) -> str:\n dashboard = \"\\n\" + \"=\"*50 + \"\\n\"\n dashboard += \" ANALYTICS DASHBOARD\\n\"\n dashboard += \"=\"*50 + \"\\n\\n\"\n \n # Overview section\n dashboard += f\"📊 OVERVIEW\\n\"\n dashboard += f\" Total Records: {record_count:,}\\n\\n\"\n \n # Statistics section\n if stats:\n dashboard += f\"📈 STATISTICS\\n\"\n for key, value in stats.items():\n dashboard += f\" {key.replace('_', ' ').title()}: {value}\\n\"\n dashboard += \"\\n\"\n \n # Trends section\n if trends:\n dashboard += f\"📅 TRENDS\\n\"\n for key, value in trends.items():\n dashboard += f\" {key.replace('_', ' ').title()}:\\n\"\n if isinstance(value, dict):\n for k, v in list(value.items())[:3]: # Show top 3\n dashboard += f\" {k}: {v}\\n\"\n dashboard += \"\\n\"\n \n # Patterns section\n if patterns:\n dashboard += f\"🔍 PATTERNS\\n\"\n for key, value in patterns.items():\n dashboard += f\" {key.replace('_', ' ').title()}:\\n\"\n for k, v in value.items():\n dashboard += f\" {k}: {v}\\n\"\n dashboard += \"\\n\"\n \n # Insights section\n if correlations:\n dashboard += f\"💡 INSIGHTS\\n\"\n dashboard += f\" {correlations}\\n\\n\"\n \n if categorical_info:\n dashboard += f\"📋 CATEGORICAL DATA\\n\"\n dashboard += f\" {categorical_info}\\n\\n\"\n \n dashboard += \"=\"*50\n \n print(dashboard)\n return dashboard",
54
+
"gui_code": "from PySide6.QtWidgets import QLabel, QTextEdit, QPushButton\nfrom PySide6.QtCore import Qt\nfrom PySide6.QtGui import QFont\n\ntitle_label = QLabel('Analytics Dashboard', parent)\ntitle_font = QFont()\ntitle_font.setPointSize(14)\ntitle_font.setBold(True)\ntitle_label.setFont(title_font)\nlayout.addWidget(title_label)\n\nwidgets['dashboard_display'] = QTextEdit(parent)\nwidgets['dashboard_display'].setMinimumHeight(250)\nwidgets['dashboard_display'].setReadOnly(True)\nwidgets['dashboard_display'].setPlainText('Generate data and run analysis to see dashboard...')\nfont = QFont('Courier New', 9)\nwidgets['dashboard_display'].setFont(font)\nlayout.addWidget(widgets['dashboard_display'])\n\nwidgets['export_btn'] = QPushButton('Export Report', parent)\nlayout.addWidget(widgets['export_btn'])\n\nwidgets['refresh_btn'] = QPushButton('Refresh Analysis', parent)\nlayout.addWidget(widgets['refresh_btn'])",
0 commit comments