You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`from azureml.opendatasets import NycTlcYellow
from datetime import datetime
from dateutil import parser
import geopandas as gpd
from shapely.geometry import Point
import pandas as pd
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
`from azureml.opendatasets import NycTlcYellow
from datetime import datetime
from dateutil import parser
import geopandas as gpd
from shapely.geometry import Point
import pandas as pd
start_date = parser.parse('2015-01-01')
end_date = parser.parse('2015-01-31')
nyc_tlc = NycTlcYellow(start_date=start_date, end_date=end_date)
taxi_data = nyc_tlc.to_pandas_dataframe()
taxi_data.info()
neighborhoods = gpd.read_file('nyc/geo_export_efe01be6-5681-4d19-b441-eefd6f6bb3fa.shp')
geometry = [Point(xy) for xy in zip(taxi_data['startLon'], taxi_data['startLat'])]
taxi_gdf = gpd.GeoDataFrame(taxi_data, geometry=geometry, crs="EPSG:4326")
taxi_with_neighborhood = gpd.sjoin(taxi_gdf, neighborhoods, how="left", predicate="within")
taxi_with_neighborhood['cost_per_mile'] = taxi_with_neighborhood['totalAmount'] / taxi_with_neighborhood['tripDistance']
taxi_with_neighborhood.reset_index(drop=True, inplace=True)
neighborhood_stats = taxi_with_neighborhood.groupby('ntaname', dropna=True).agg({
'cost_per_mile': ['sum', 'count']
}).reset_index()
neighborhood_stats.head()
taxi_with_neighborhood['cost_per_mile'][0]
cost_per_mile_sum = taxi_with_neighborhood.groupby('ntaname')['cost_per_mile'].sum()
print(cost_per_mile_sum)
taxi_with_neighborhood_pdf = pd.DataFrame(taxi_with_neighborhood)
neighborhood_stats = taxi_with_neighborhood.groupby('ntaname', dropna=True).agg({
'cost_per_mile': ['sum', 'count']
}).reset_index()
neighborhood_stats.head()
pd.show_versions()
`
Expected Behavior
should return float values for sum
Installed Versions
INSTALLED VERSIONS
commit : 0f43794
python : 3.10.15.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.0-32-cloud-amd64
Version : #1 SMP Debian 5.10.223-1 (2024-08-10)
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.0.3
numpy : 1.24.4
pytz : 2024.2
dateutil : 2.9.0
setuptools : 74.1.2
pip : 24.2
Cython : 3.0.11
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.21.0
pandas_datareader: None
bs4 : 4.12.3
bottleneck : None
brotli : 1.1.0
fastparquet : None
fsspec : 2024.9.0
gcsfs : 2024.9.0post1
matplotlib : 3.7.3
numba : 0.58.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.4
snappy : None
sqlalchemy : 2.0.35
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : 0.23.0
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: