MySQL to Pandas DataFrame Converter

Transform MySQL database dumps into Python Pandas DataFrame format for data analysis

MySQL Input

Pandas DataFrame Output

About MySQL to Pandas DataFrame Converter

Convert MySQL database dumps (CREATE TABLE and INSERT statements) to Python Pandas DataFrame code with automatic type detection. Perfect for data analysis, machine learning, and scientific computing with Python.

Key Features

  • Automatic Type Detection: Intelligently detects int64, float64, bool, and object types
  • Two Output Formats: Dictionary (column-oriented) or List of Lists (row-oriented)
  • NumPy Integration: Uses np.nan for NULL values
  • Type Annotations: Includes comments showing detected data types
  • Ready to Run: Generates complete Python code with imports
  • DataFrame Info: Includes code to display shape and column types
  • File Download: Save as .py file for immediate use

How to Use

  1. Input MySQL Data: Paste your MySQL CREATE TABLE and INSERT statements or upload a .sql file
  2. Choose Format: Select dictionary or list of lists output format
  3. Review Output: The Pandas DataFrame code generates automatically
  4. Copy or Download: Use the Copy or Download button to save your code
  5. Run in Python: Execute the code in Jupyter, Python script, or interactive shell

Output Formats

  • Dictionary (column-oriented): Each column is a key with list of values - efficient for column operations
  • List of Lists (row-oriented): Each row is a list - efficient for row operations

Type Detection

  • int64: Integer values (INT, BIGINT)
  • float64: Decimal numbers (DECIMAL, FLOAT, DOUBLE)
  • bool: Boolean values (BOOLEAN, TINYINT(1))
  • object: String and mixed-type data (VARCHAR, TEXT, CHAR)
  • np.nan: NULL or empty values

Example Conversion

MySQL Input:

CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  age INT,
  salary DECIMAL(10,2)
);

INSERT INTO employees VALUES (1, 'John Doe', 28, 75000.00);
INSERT INTO employees VALUES (2, 'Jane Smith', 34, 82000.50);

Pandas DataFrame Output (Dictionary):

import pandas as pd
import numpy as np

data = {
    'id': [1, 2],  # int64
    'name': ['John Doe', 'Jane Smith'],  # object
    'age': [28, 34],  # int64
    'salary': [75000.00, 82000.50],  # float64
}

df = pd.DataFrame(data)

# Display DataFrame info
print(df.head())
print("\nDataFrame shape:", df.shape)
print("\nColumn types:")
print(df.dtypes)

Common Use Cases

  • Data Analysis: Import MySQL data into Pandas for statistical analysis
  • Machine Learning: Prepare database data for ML models
  • Data Visualization: Create charts and graphs with matplotlib/seaborn
  • ETL Pipelines: Transform MySQL data in Python workflows
  • Jupyter Notebooks: Analyze database exports in interactive notebooks
  • Data Science: Perform scientific computing on database data

Pandas DataFrame Operations

Once you have the DataFrame, you can perform various operations:

  • Filtering: df[df['age'] > 30]
  • Sorting: df.sort_values('salary', ascending=False)
  • Grouping: df.groupby('city').mean()
  • Statistics: df.describe(), df.mean(), df.std()
  • Merging: pd.merge(df1, df2, on='id')
  • Exporting: df.to_csv(), df.to_excel(), df.to_json()

Supported MySQL Data Types

  • Numeric: INT, BIGINT, DECIMAL, FLOAT, DOUBLE → int64/float64
  • String: VARCHAR, CHAR, TEXT, MEDIUMTEXT, LONGTEXT → object
  • Boolean: BOOLEAN, TINYINT(1) → bool
  • NULL: NULL values → np.nan

Requirements

To run the generated code, you need:

  • Python 3.6 or higher
  • pandas library: pip install pandas
  • numpy library: pip install numpy (usually installed with pandas)

Tips for Best Results

  • Use dictionary format for column-heavy operations
  • Use list of lists format for row-heavy operations
  • Check data types after loading with df.dtypes
  • Convert types if needed: df['column'].astype('int64')
  • Handle missing values: df.fillna(0) or df.dropna()
  • Set index if needed: df.set_index('id', inplace=True)

Privacy & Security

All conversions happen locally in your browser. Your MySQL data is never uploaded to any server, ensuring complete privacy and security.