Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0bde4e1

Browse files
authored
Merge pull request plotly#980 from plotly/windows-choropleth
USA Choropleths OSError fixed in Windows
2 parents 2f59570 + 2260054 commit 0bde4e1

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [2.5.1] - 2018-03-26
6+
### Fixed
7+
- `plotly.figure_factory.create_choropleth` now works in Windows without raising an OSError. The module now uses cross-platform path tools from `os` to manipulate and manage the shapefiles contained in this package.
8+
59
## [2.5.0] - 2018-03-12
610
### Fixed
711
- `import plotly.figure_factory` does not fail if `pandas` is not installed. See https://github.com/plotly/plotly.py/pull/958

plotly/figure_factory/_county_choropleth.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ def _create_us_counties_df(st_to_state_name_dict, state_to_st_dict):
2323
abs_file_path = os.path.realpath(__file__)
2424
abs_dir_path = os.path.dirname(abs_file_path)
2525

26-
abs_plotly_dir_path = abs_dir_path[:abs_dir_path.find('/figure_factory')]
27-
abs_package_data_dir_path = abs_plotly_dir_path + '/package_data/'
26+
abs_plotly_dir_path = os.path.dirname(abs_dir_path)
27+
28+
abs_package_data_dir_path = os.path.join(abs_plotly_dir_path,
29+
'package_data')
2830

2931
shape_pre2010 = 'gz_2010_us_050_00_500k.shp'
30-
shape_pre2010 = abs_package_data_dir_path + shape_pre2010
32+
shape_pre2010 = os.path.join(abs_package_data_dir_path, shape_pre2010)
33+
3134
df_shape_pre2010 = gp.read_file(shape_pre2010)
3235
df_shape_pre2010['FIPS'] = (df_shape_pre2010['STATE'] +
3336
df_shape_pre2010['COUNTY'])
3437
df_shape_pre2010['FIPS'] = pd.to_numeric(df_shape_pre2010['FIPS'])
3538

3639
states_path = 'cb_2016_us_state_500k.shp'
37-
states_path = abs_package_data_dir_path + states_path
40+
states_path = os.path.join(abs_package_data_dir_path, states_path)
3841

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

4851
for j in range(len(filenames)):
49-
filenames[j] = abs_package_data_dir_path + filenames[j]
52+
filenames[j] = os.path.join(abs_package_data_dir_path, filenames[j])
5053

5154
dbf = io.open(filenames[0], 'rb')
5255
shp = io.open(filenames[1], 'rb')

plotly/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.5.0'
1+
__version__ = '2.5.1'

0 commit comments

Comments
 (0)