Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de5d242

Browse filesBrowse files
committed
construct paths to choropleth files intelligently
1 parent 2f59570 commit de5d242
Copy full SHA for de5d242

File tree

Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed

‎plotly/figure_factory/_county_choropleth.py

Copy file name to clipboardExpand all lines: plotly/figure_factory/_county_choropleth.py
+8-5Lines 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')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.