#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1058
Task: Write a Python function that analyzes wonder_attempts table and identifies which task categories succeed most
Generated: 2026-02-12T18:31:35.543215
"""

import pandas as pd

def analyze_wonder_attempts(wonder_attempts):
    # Group by task_category and count the number of successes
    success_counts = wonder_attempts.groupby('task_category')['success'].sum()
    
    # Sort by success counts in descending order
    sorted_success = success_counts.sort_values(ascending=False)
    
    # Print the result
    print("Task categories that succeed most:")
    for category, count in sorted_success.items():
        print(f"{category}: {count} successes")
    
    return sorted_success

if __name__ == '__main__':
    # Example data
    data = {
        'task_category': ['Math', 'Physics', 'Math', 'Chemistry', 'Physics', 'Math', 'Chemistry'],
        'success': [1, 0, 1, 1, 1, 1, 0]
    }
    wonder_attempts = pd.DataFrame(data)
    analyze_wonder_attempts(wonder_attempts)