Stephen Stephen - 1 year ago 105
Python Question

orderedDict vs pandas series

Still new to this, sorry if I ask something really stupid. What are the differences between a Python ordered dictionary and a pandas series?

The only difference I could think of is that an orderedDict can have nested dictionaries within the data. Is that all? Is that even true?

Would there be a performance difference between using one vs the other?

My project is a sales forecast, most of the data will be something like: {Week 1 : 400 units, Week 2 : 550 units}... Perhaps an ordered dictionary would be redundant since input order is irrelevant compared to Week#?

Again I apologize if my question is stupid, I am just trying to be thorough as I learn.

Thank you!


Answer Source

Most importantly, pd.Series is part of the pandas library so it comes with a lot of added functionality - see attributes and methods as you scroll down the pd.Series docs. This compares to OrderDict: docs.

For your use case, using pd.Series or pd.DataFrame (which could be a way of using nested dictionaries as it has an index and multiple columns) seem quite appropriate. If you take a look at the pandas docs, you'll also find quite comprehensive time series functionality that should come in handy for a project around weekly sales forecasts.

Since pandas is built on numpy, the specialized scientific computing package, performance is quite good.