File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
packages/python/plotly/plotly/data Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,11 @@ def gapminder(
51
51
df = df .filter (nw .col ("year" ) == year )
52
52
if datetimes :
53
53
df = df .with_columns (
54
- nw .concat_str ([nw .col ("year" ).cast (nw .String ()), nw .lit ("-01-01" )]).cast (
55
- nw .Datetime (time_unit = "ns" )
56
- )
54
+ # Concatenate the year value with the literal "-01-01" so that it can be
55
+ # casted to datetime from "%Y-%m-%d" format
56
+ nw .concat_str (
57
+ [nw .col ("year" ).cast (nw .String ()), nw .lit ("-01-01" )]
58
+ ).str .to_datetime (format = "%Y-%m-%d" )
57
59
)
58
60
if not centroids :
59
61
df = df .drop ("centroid_lat" , "centroid_lon" )
@@ -403,7 +405,12 @@ def _get_dataset(d, return_type):
403
405
404
406
try :
405
407
backend = import_module (return_type )
406
- return backend .read_csv (filepath )
407
408
except ModuleNotFoundError :
408
409
msg = f"return_type={ return_type } , but { return_type } is not installed"
409
410
raise ModuleNotFoundError (msg )
411
+
412
+ try :
413
+ return backend .read_csv (filepath )
414
+ except Exception as e :
415
+ msg = f"Unable to read '{ d } ' dataset due to: { e } "
416
+ raise Exception (msg ).with_traceback (e .__traceback__ )
You can’t perform that action at this time.
0 commit comments