Data AnalysisAI ToolsBusiness Intelligence
AI-Powered Data Analysis: From Spreadsheets to Insights
212AY Team·2026-04-20·11 min
import pandas as pd
import matplotlib.pyplot as plt
from openai import OpenAI
client = OpenAI()
def analyze_dataframe(df, question):
# Get dataframe info
info = f"Columns: {list(df.columns)}\n"
info += f"Shape: {df.shape}\n"
info += f"Sample:\n{df.head().to_string()}"
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "Analyze this data and answer the question. Include Python code if relevant."},
{"role": "user", "content": f"Data:\n{info}\n\nQuestion: {question}"}
]
)
return response.choices[0].message.content
Use Case: Moroccan E-commerce
A small business in Marrakech used AI to analyze their sales data and discovered:
- 60% of revenue came from returning customers (not new)
- Their best-selling products had predictable seasonal dips
- WhatsApp was their most effective marketing channel
They adjusted their strategy and increased revenue by 35% in one quarter.