79779389

Date: 2025-09-30 17:57:51
Score: 1
Natty:
Report link

You can apply a map to the index for formatting.

df.index = df.index.map(lambda x: f"{x:.2e}")

Full Example Code:

import pandas as pd
data = {
    "Name": ["Alice", "Charlie", "Alex"],
    "Age": [25, 30, 35],
    "Score": [88.5, 85.0, 91.5]
}

# Create DataFrame
df = pd.DataFrame(data)

# Set index values
index_values =[1000000, 10000000, 100000000]

# Format index
df.index = df.index.map(lambda x: f"{x:.2e}")

Output df

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: pixel-process