For questions about contributing to pandas, please ask in the pandas-dev/community channel
import *
Hi pandas wizards! I've had a really peculiar problem with the pandas DatetimeIndex
.
The problem appeared in the sktime CI pipelines and the code was working well on Linux and Mac but was failing on Windows.
sktime has a pandas<=1.1.5 so maybe this is not a problem in the recent versions, but it's worth a check.
The core problem was that for Linux and Mac, after some indexing/filtering operations on a multiindex dataframe, the resulting series had a DatetimeIndex
with the right frequency, but for windows the frequency was None
. The fix was to add this:
if hasattr(item.index, "freq") and item.index.freq is None:
item.index.freq = pd.infer_freq(item.index)
Here you can find the CI logs from a dummy PR I did to debug this:
alan-turing-institute/sktime#2224
and here is the code were I applied the fix:
https://github.com/alan-turing-institute/sktime/blob/dddcd2c31f6400db1ca791c0d16d549d756ccab5/sktime/datatypes/_vectorize.py#L152
The quick-fix works, so no rush, but I'm really curious to figure out what the real cause is.
pandas-stubs
for as typing stubs for pandas but it's not up-to-date and i just realized there's already pyi
files in sources of pandas. Anyone here found a way of running mypy on a project using pandas using those stubs? Are they packages with pandas ?
nans = [np.nan,None,pd.NaT, pd.NA] #all possible nan values that I could think of
for nan in nans:
if nan in dictionary:
del dictionary[nan]
Thanks in advance
Hi all,
I want to debug run a specific test in the pandas source code with Pycharm.
But it fails with the following error:
C:\Users\hoge\miniforge3\envs\pandas-dev\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py" --path C:/Users/hoge/PycharmProjects/pandas/pandas/tests/io/parser/test_parse_dates.py
Testing started at 22:52 ...
Launching pytest with arguments C:/Users/hoge/PycharmProjects/pandas/pandas/tests/io/parser/test_parse_dates.py --no-header --no-summary -q in C:\Users\hoge\PycharmProjects\pandas\pandas\tests\io\parser
ImportError while loading conftest 'C:\Users\hoge\PycharmProjects\pandas\pandas\conftest.py'.
..\..\..\__init__.py:22: in <module>
from pandas.compat import is_numpy_dev as _is_numpy_dev
..\..\..\compat\__init__.py:15: in <module>
from pandas.compat.numpy import (
..\..\..\compat\numpy\__init__.py:4: in <module>
from pandas.util.version import Version
..\..\..\util\__init__.py:1: in <module>
from pandas.util._decorators import ( # noqa:F401
..\..\..\util\_decorators.py:14: in <module>
from pandas._libs.properties import cache_readonly # noqa:F401
..\..\..\_libs\__init__.py:13: in <module>
from pandas._libs.interval import Interval
E ModuleNotFoundError: No module named 'pandas._libs.interval'
Process finished with exit code 4
Empty suite
Let me know if you have any ideas for this ModuleNotFoundError
.
Hi all, I would like to ask if it is possible to pass in the group name to the function when doing groupby/apply?
For example, if I do this, I can get the group name:
for group, frame in data.groupby([“some group”]):
print(group)
# do something with frame
If I do this instead, I only get the frame as argument, and I don’t have the group name to even pass as extra argument.
results = data.groupby([“some group”]).apply(transform_func)
def pandasSQL_builder(con, schema: str | None = None):
return SQLDatabase(con, schema=schema)```
this gives me an AttributeError: module 'sqlalchemy.engine' has no attribute 'Connectable'. Did you mean: 'Connection'?
con
parameter as My connection string in such case this method call SQLAlchemy's create_engine() which returns an Engine Object. how can this be compared with the engine.Connections or engine.Connectable ?