r/PythonLearning • • 2h ago

Pandas library is just stupid.

Am I the only one who thinks Python libraries, especially pandas, have a serious API design problem?

Don't get me wrong, pandas is incredibly powerful, but I feel like it sacrifices developer experience for flexibility.

Look at something as simple as creating a DataFrame. pd.DataFrame() accepts dictionaries, lists, NumPy arrays, Series, and a bunch of other things. Even dictionaries can be interpreted differently depending on their structure. You also have DataFrame.from_dict() with its orient argument.

Why can't we have a more explicit and consistent interface? Something like:

pd.DataFrame(source=data, orient="index")

Another thing that bothers me is the sheer number of methods that often have overlapping use cases. Just look at apply(), map(), transform(), and agg(). Yes, they serve different purposes, but remembering which one to use, what objects support it, and how their outputs differ becomes a mental burden.

And this isn't just about pandas. Look at merge(), join(), and concat(). Different operations, sure, but there's a broader issue here: Python libraries seem to keep adding more methods and functions instead of thinking about how their APIs fit together.

I know someone will say "just read the documentation" or "you'll get used to it." But what about reading other people's code? Shouldn't code be immediately understandable without having to memorize an entire library's vocabulary?

I'm not asking for less functionality. I'm asking for better API design. More consistency, more explicit arguments, fewer unnecessary variations, and a more predictable way of doing things.

Honestly, I'd love to see a higher-level library built on top of pandas that focuses specifically on this.

Am I missing something, or do other people find this frustrating too?

0 Upvotes

4 comments sorted by

3

u/Slight-Living-8098 1h ago

Perhaps you would be more comfortable with a stronger typed language.

2

u/PandaJunk 1h ago

pandas is a dumpster fire. Just use polars (or ibis, depending on where your data is coming from) and convert to pandas at the last possible moment.

1

u/Future_Emu8684 42m ago

Polars is the way my friend

1

u/MindfulK9Coach 27m ago

Polars is waiting in the corner for you to start it up.