Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USA Choropleths OSError fixed in Windows #980

Merged
merged 4 commits into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.5.1] - 2018-03-26
### Fixed
- `plotly.figure_factory.create_choropleth` now works in Windows without raising an OSError. The module now uses intelligent path tools from `os` to manipulate and manage the shapefiles packaged with Plotly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of "intelligent", maybe "cross-platform"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manage the shapefiles packaged with Plotly

"manage the shapefiles contained in this package."


## [2.5.0] - 2018-03-12
### Fixed
- `import plotly.figure_factory` does not fail if `pandas` is not installed. See https://github.com/plotly/plotly.py/pull/958
Expand Down
13 changes: 8 additions & 5 deletions plotly/figure_factory/_county_choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ def _create_us_counties_df(st_to_state_name_dict, state_to_st_dict):
abs_file_path = os.path.realpath(__file__)
abs_dir_path = os.path.dirname(abs_file_path)

abs_plotly_dir_path = abs_dir_path[:abs_dir_path.find('/figure_factory')]
abs_package_data_dir_path = abs_plotly_dir_path + '/package_data/'
abs_plotly_dir_path = os.path.dirname(abs_dir_path)

abs_package_data_dir_path = os.path.join(abs_plotly_dir_path,
'package_data')

shape_pre2010 = 'gz_2010_us_050_00_500k.shp'
shape_pre2010 = abs_package_data_dir_path + shape_pre2010
shape_pre2010 = os.path.join(abs_package_data_dir_path, shape_pre2010)

df_shape_pre2010 = gp.read_file(shape_pre2010)
df_shape_pre2010['FIPS'] = (df_shape_pre2010['STATE'] +
df_shape_pre2010['COUNTY'])
df_shape_pre2010['FIPS'] = pd.to_numeric(df_shape_pre2010['FIPS'])

states_path = 'cb_2016_us_state_500k.shp'
states_path = abs_package_data_dir_path + states_path
states_path = os.path.join(abs_package_data_dir_path, states_path)

# state df
df_state = gp.read_file(states_path)
Expand All @@ -46,7 +49,7 @@ def _create_us_counties_df(st_to_state_name_dict, state_to_st_dict):
'cb_2016_us_county_500k.shx']

for j in range(len(filenames)):
filenames[j] = abs_package_data_dir_path + filenames[j]
filenames[j] = os.path.join(abs_package_data_dir_path, filenames[j])

dbf = io.open(filenames[0], 'rb')
shp = io.open(filenames[1], 'rb')
Expand Down
2 changes: 1 addition & 1 deletion plotly/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.5.0'
__version__ = '2.5.1'