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(
5151 df = df .filter (nw .col ("year" ) == year )
5252 if datetimes :
5353 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" )
5759 )
5860 if not centroids :
5961 df = df .drop ("centroid_lat" , "centroid_lon" )
@@ -403,7 +405,12 @@ def _get_dataset(d, return_type):
403405
404406 try :
405407 backend = import_module (return_type )
406- return backend .read_csv (filepath )
407408 except ModuleNotFoundError :
408409 msg = f"return_type={ return_type } , but { return_type } is not installed"
409410 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