Python
Pandas Online Compiler
import pandas as pd works straight away: pandas 3.1 is installed for every Python version in Run settings, with NumPy and openpyxl. The editor opens with a sales table that the script groups, pivots and saves to by_region.csv, which opens as a new tab when the run ends.
Try it aboveHow Python runs here
- Versions
- Python 3.11, 3.12 (default), 3.13, 3.14, 3.15
- Run
python3 -u main.py- Limits per run
- 256 MB memory, 15 s of CPU time on 2 cores, 2 MB of output
- Time
- Up to 10 minutes a run (30 on a paid plan); waits 2 minutes for input (5 on a paid plan)
- Sandbox
- Each run gets its own Linux sandbox with no network access. Text files your program writes next to your code open as new tabs.
- Good to know
- NumPy, pandas, Matplotlib and openpyxl installed.
What the starter script prints
Press Run and the terminal shows the three tables:
$ python3 -u main.py month region units price revenue 0 Jan North 120 9.5 1140.0 1 Jan South 95 9.5 902.5 2 Feb North 140 9.5 1330.0 3 Feb South 110 10.0 1100.0 4 Mar North 160 10.0 1600.0 5 Mar South 105 10.0 1050.0 units revenue region North 420 4070.0 South 310 3052.5 region North South month Jan 120 95 Feb 140 110 Mar 160 105 Saved by_region.csv
by_region.csv is a text file next to main.py, so it opens as a tab:
region,units,revenue North,420,4070.0 South,310,3052.5
sort=False in pivot_table() keeps the months in the order they appear; without it they’d be sorted alphabetically (Feb, Jan, Mar).
Your own data
Upload a CSV, TSV, JSON or text file with the upload button, then read it by name. input() waits for you to type in the terminal, so a script can ask what to show:
import pandas as pd df = pd.read_csv("data.csv") # a CSV you uploaded next to main.py print(df.shape) print(df.dtypes) print(df.head()) region = input("Region to show: ") print(df[df["region"] == region].sort_values("units", ascending=False))
- The playground takes text files only: an .xlsx upload is refused as not a text file, and a file written with to_excel() doesn’t come back. In a project (sign in), binary files are kept, so read_excel() and to_excel() work there with openpyxl.
- Files your script writes at the top level, from to_csv(), to_json() or to_string(), open as new tabs. Files in subfolders don’t come back to the playground.
- Wide tables wrap in the terminal. pd.set_option("display.width", 200) or df.to_string() keeps rows on one line.
pandas 3 changes that break older code
- Copy-on-Write is always on. df[df["a"] > 1]["b"] = 0 never changes df, and pandas warns with ChainedAssignmentError. Write df.loc[df["a"] > 1, "b"] = 0. SettingWithCopyWarning no longer exists.
- Text columns use the new str dtype: df.dtypes shows str rather than object.
- DataFrame.append() is gone (since 2.0). Collect rows in a list and call pd.concat() or pd.DataFrame(rows) once.
- A number column read as text adds up by joining: a price column holding "9.5" and "10" sums to 9.510. Convert it with pd.to_numeric(df["price"], errors="coerce").
What isn’t available here
- pyarrow and fastparquet, so read_parquet() and to_parquet() fail. Use CSV or JSON.
- xlrd, so old .xls files can’t be read; .xlsx works through openpyxl in a project.
- Charts. df.plot() needs an image, and the playground shows text output only.
- The network: read_csv("https://...") can’t download. Upload the file instead.
Errors you’ll see
- “KeyError: 'region'” No column has that exact name; check capitals and spaces with print(df.columns.tolist()).
- “FileNotFoundError: [Errno 2] No such file or directory: 'data.csv'” The file isn’t uploaded, or its name differs. Names are case-sensitive.
- “TypeError: Cannot perform reduction 'mean' with string dtype” The column is text. Convert it with pd.to_numeric() first.
- “AttributeError: 'DataFrame' object has no attribute 'append'” Code written for pandas 1.x. Use pd.concat().
- “ImportError: Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'.” Parquet needs pyarrow, which isn’t installed.
When code from an older tutorial fails, Fix with AI under the failed run proposes the pandas 3 equivalent as a diff.
Questions
Which pandas version is installed?
pandas 3.1, on every Python version in Run settings (3.12 is the default), together with NumPy and openpyxl.
Can I download the CSV my code writes?
Yes. A CSV written next to main.py opens as a tab, and you can download it or all files as a zip.
Can I read Excel files?
In a project, yes: binary files are kept there and openpyxl reads .xlsx. The playground accepts text files only, so convert the sheet to CSV to use it there.
Why doesn’t my assignment change the DataFrame?
pandas 3 uses Copy-on-Write, so chained indexing like df[mask]["col"] = value sets a copy. Use df.loc[mask, "col"] = value.
Can I make charts with pandas here?
No. The playground shows text output only; print tables with df.to_string() or summaries with describe().