-
Notifications
You must be signed in to change notification settings - Fork 4
Code Style and Conventions
Before #4384, pandas
depended on the 2to3
tool to ensure that the codebase was Python 2 and 3 compatible. This is not the case anymore. That means that you should be careful about writing code that is Python 2 and Python 3 compatible. To that end, there are new internal functions that abstract away the details of the API changes between the two major versions of Python along with the six
module now shipped with pandas
.
In particular, there are the functions lrange
, lzip
, lmap
, lreduce
, and lfilter
which all return lists no matter what version of Python is used. These functions live in the pandas.util.compat
module.
These are the equivalent of wrapping each of range
, zip
, map
, reduce
, or filter
in a call to the list
constructor, e.g. list(zip(...))
. It is advised to use these functions when you know you need a list
object and to use the others when you need to iterate over the resulting object.