Skip to main content

Troubleshooting Guide

Common issues and their solutions for NetSuite Python Report development.


Python & Pandas Issues

"ModuleNotFoundError: No module named 'pandas'"

Cause: Pandas package is not installed.

Solution:

pip install pandas xlsxwriter numpy openpyxl

"KeyError: 'column_name'"

Cause: The column doesn't exist in the DataFrame.

Solution:

# Check if column exists first
if 'column_name' in df.columns:
result = df['column_name']
else:
print(f"Available columns: {list(df.columns)}")

"TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'"

Cause: Null values in numeric calculations.

Solution:

# Fill null values before calculations
df = df.fillna(0)

# Or fill specific columns
df['amount'] = df['amount'].fillna(0)

DataFrame shows NaN instead of values

Cause: Data contains null/undefined values from JavaScript.

Solution:

// JavaScript side - sanitize nulls
window.data = JSON.stringify(dataArray).replaceAll(null, 'null');
# Python side
df = df.fillna(0) # for numbers
df = df.fillna('') # for strings

XlsxWriter Issues

"Exception: Worksheet name 'xxx' is already in use"

Cause: Trying to create a worksheet with the same name twice.

Solution:

# Use unique worksheet names
worksheet1 = workbook.add_worksheet('AR Report')
worksheet2 = workbook.add_worksheet('AP Report') # Different name

"Exception: Cell merge overlaps"

Cause: Trying to merge cells that are already part of another merge.

Solution:

# Ensure merge ranges don't overlap
# Check your row/column calculations
print(f"Merge 1: {r1},{c1} to {r2},{c2}")
print(f"Merge 2: {r3},{c3} to {r4},{c4}")

Format not applied to cells

Cause: Format created after writing data, or wrong format object used.

Solution:

# Create formats BEFORE writing data
header_format = workbook.add_format({'bold': True})

# Apply format when writing
worksheet.write(0, 0, 'Header', header_format)

Numbers showing as text in Excel

Cause: Writing numbers as strings.

Solution:

# Convert to number before writing
value = float(row['amount']) # or int()
worksheet.write(row_num, col_num, value, number_format)

Pyodide Issues

Pyodide hangs or takes very long

Cause: Large data processing or infinite loop.

Solution:

# Process data in chunks
from js import console

for i in range(0, len(data), 1000):
chunk = data[i:i+1000]
console.log(f"Processing chunk {i//1000 + 1}")
process_chunk(chunk)

"Can't import from js"

Cause: Variable not set in window before running Python.

Solution:

// JavaScript - set BEFORE running Python
window.myData = JSON.stringify(data);
# Python
from js import myData

Package import fails in Pyodide

Cause: Package not loaded before importing.

Solution:

// Load packages in correct order
await pyodide.loadPackage("micropip");

const micropip = pyodide.pyimport("micropip");
await micropip.install('pandas');
await micropip.install('xlsxwriter');

// Now run Python code that imports these packages

Jupyter Notebook Issues

Kernel keeps dying

Cause: Memory issue or corrupted kernel.

Solution:

  1. Restart VS Code
  2. Clear all outputs: Click "Clear All Outputs" button
  3. Reduce data size in test files
  4. Upgrade ipykernel: pip install --upgrade ipykernel

"No kernel" or "Select a kernel"

Cause: Python interpreter not selected.

Solution:

  1. Click "Select Kernel" in top-right
  2. Choose "Python Environments"
  3. Select your Python installation

Output not showing

Cause: Cell output cleared or collapsed.

Solution:

  1. Clear All Outputs
  2. Re-run the cell
  3. Check for errors in output area

Excel Output Issues

Wrong row positions

Cause: Row index calculation errors.

Solution:

# Debug row positions
print(f"Header row: {header_row}")
print(f"Data start: {data_start_row}")
print(f"Data end: {data_end_row}")
print(f"Total rows: {len(df)}")

Column widths too narrow

Cause: Column width not set or set too small.

Solution:

# Set appropriate column widths
worksheet.set_column('A:A', 30) # Name column - wider
worksheet.set_column('B:B', 10) # Currency - narrow
worksheet.set_column('C:N', 15) # Numbers - medium

Special characters not displaying

Cause: Encoding issues.

Solution:

# When reading files
with open('file.json', 'r', encoding='utf-8') as f:
data = json.load(f)

Data Issues

Empty DataFrame

Cause: No data returned from query or filter.

Solution:

# Check data at each step
print(f"Original records: {len(original_data)}")
print(f"After filter: {len(filtered_df)}")

if len(filtered_df) == 0:
print("No data matches the filter criteria")

Wrong data types

Cause: Numbers stored as strings.

Solution:

# Convert to correct types
df['amount'] = pd.to_numeric(df['amount'], errors='coerce')
df['date'] = pd.to_datetime(df['date'], format='%d/%m/%Y')

Duplicate rows

Cause: Data loaded multiple times or concat without reset.

Solution:

# Remove duplicates
df = df.drop_duplicates()

# Reset index after concat
df = df.reset_index(drop=True)

Quick Diagnostic Commands

Run these to diagnose issues:

# Check DataFrame
print(f"Shape: {df.shape}")
print(f"Columns: {list(df.columns)}")
print(f"Types: {df.dtypes}")
print(f"Nulls: {df.isnull().sum()}")

# Check data sample
df.head()
df.info()

# Check specific values
print(df['column'].unique())
print(df['column'].describe())

Getting Help Checklist

When asking for help, provide:

  1. Error message - Full error text
  2. Code snippet - Relevant code causing the error
  3. Data sample - First few rows of your data
  4. What you tried - Steps already attempted
  5. Expected vs actual - What should happen vs what happened