Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
# Imports
import numpy as np
import pandas as pd
# Values
nsteps = 5*10**6
sv = np.random.normal(loc=100.0, scale=1.0, size=nsteps+1)
# Series with int index
se = pd.Series(sv)
# Series with float index
flind = np.arange(nsteps+1)/nsteps
sef = pd.Series(sv, index=flind)
# Group with int index works
seg = se.groupby(level=0).last()
# Group with float index and size<1000000 works
sefg = sef.iloc[:999999].groupby(level=0).last()
# Group with float index and size>=1000000 doesn't work
sefg2 = sef.iloc[:1000000].groupby(level=0).last()
Problem description
Series.groupby returns an error if index is float and size is >= 1000000 (no problem with this size if index is int):
File "pandas/_libs/index.pyx", line 345, in pandas._libs.index._bin_search
TypeError: '<' not supported between instances of 'float' and 'NoneType'
Expected Output
sefg2 should be similar to sefg (with one additional row)
Output of pd.show_versions()
INSTALLED VERSIONS
commit : d9fff27
python : 3.7.7.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.0
numpy : 1.19.0
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.1.0.post20200704
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.0
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.50.1