Closed lahdjirayhan closed 2 years ago
Ozone provides a way to automatically save the returned data into a file (csv, xlsx, json). There is a room for improvement here.
The user obviously needs to supply a location for the file output, but it's very not intuitive and clunky to do so. They have to:
ozone_output
located/created there,1 & 2 are specified when instantiating Ozone, and 3 is specified when calling one of Ozone's public method through the data_format
argument.
This can be improved, by either of the following:
Remove the convenience feature of saving the file. Just return the dataframe and let the user handle it if they want to save. For what it's worth, this is not an unreasonable thing to do, given that all users need to do is to call df.to_csv
or something else (Ozone does exactly just that under the hood).
If this option is considered unacceptable, I still propose to simplify
ozone_output
subdirectory. Default: current working directory.data_format
other than df
, e.g. get_city_air('London', data_format='xlsx', filename='something')
will write to something.xlsx
. Default: None.
If None, we can choose to either:
Doing this option implies removing file_name
argument from __init__
and adding something like it into public methods instead.
Conceptually same as Option 2 but only number 2. User can't specify a custom subfolder and if they want to, they'll have to supply something like filename='subfolder/filename'
to public methods.
Doing the above introduces breaking changes. If we are going to make changes, might as well do it now and collect all the breaking changes together before moving to v2.
P.S.: I'm not sure where to put this (v2 discussion thread? start discussion? open issue?) but yeah I'll just put it here.
P.P.S.: Too late for v2, but never mind.
@lahdjirayhan
I think option one is best. Let's open a separate issue to address the changes that you mentioned there.
Describe the bug The warning emitted when not giving custom file name is inappropriate/misleading.
To Reproduce
Just instantiate an Ozone object and you'll get a warning for not giving a custom filename.
The following message appears:
UserWarning: You have not specified a custom save file name. Existing files with the same name may be overwritten!
If you try to give a custom filename for output files, the warning won't appear.
However, if you save into a file, the filename remains 'something_custom' and will get overwritten.
Proposed solution for better behavior
See comment below.
Environment