@@ -30,10 +30,7 @@ def _to_pandas_multiple(glider_grab):
30
30
glider_grab_copy = copy (glider_grab )
31
31
for dataset_id in glider_grab_copy .datasets ["Dataset ID" ]:
32
32
glider_grab_copy .fetcher .dataset_id = dataset_id
33
- df = glider_grab_copy .fetcher .to_pandas (
34
- index_col = "time (UTC)" ,
35
- parse_dates = True ,
36
- )
33
+ df = glider_grab_copy .fetcher .to_pandas ()
37
34
dataset_url = glider_grab_copy .fetcher .get_download_url ().split ("?" )[0 ]
38
35
df = standardise_df (df , dataset_url )
39
36
df_all .update ({dataset_id : df })
@@ -45,8 +42,11 @@ def standardise_df(df, dataset_url):
45
42
Standardise variable names in a dataset and add column for url
46
43
"""
47
44
df .columns = df .columns .str .lower ()
48
- df .rename (columns = dict (server_parameter_rename ), inplace = True )
49
- df .index .rename ("time" , inplace = True )
45
+ df = df .set_index ("time (utc)" )
46
+ df = df .rename (columns = server_parameter_rename )
47
+ df .index = pd .to_datetime (df .index )
48
+ # We need to sort b/c of the non-sequential submission of files due to the nature of glider data transmission.
49
+ df = df .sort_index ()
50
50
df ["dataset_url" ] = dataset_url
51
51
return df
52
52
@@ -79,10 +79,7 @@ def to_pandas(self):
79
79
:return: pandas dataframe with datetime UTC as index, multiple dataset_ids dataframes are stored in a dictionary
80
80
"""
81
81
if self .fetcher .dataset_id :
82
- df = self .fetcher .to_pandas (
83
- index_col = "time (UTC)" ,
84
- parse_dates = True ,
85
- )
82
+ df = self .fetcher .to_pandas ()
86
83
elif not self .fetcher .dataset_id and self .datasets is not None :
87
84
df_all = _to_pandas_multiple (self )
88
85
# We need to reset to avoid fetching a single dataset_id when making multiple requests.
@@ -93,7 +90,7 @@ def to_pandas(self):
93
90
f"Must provide a { self .fetcher .dataset_id } or `query` terms to download data." ,
94
91
)
95
92
96
- # Standardize variable names.
93
+ # Standardize variable names for the single dataset_id .
97
94
dataset_url = self .fetcher .get_download_url ().split ("?" )[0 ]
98
95
df = standardise_df (df , dataset_url )
99
96
return df
0 commit comments