Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return NaN, not zero, in metadata export for bins w/o depth information #381

Open
joefutrelle opened this issue Oct 4, 2023 · 4 comments
Assignees

Comments

@joefutrelle
Copy link
Contributor

No description provided.

@joefutrelle joefutrelle self-assigned this Oct 4, 2023
@joefutrelle
Copy link
Contributor Author

During metadata upload, a depth value for a bin is not set if there is no value in the uploaded CSV:

if depth_col is not None:
depth = get_cell(row, depth_col)
if depth is not None:
b.depth = depth

During metadata download, there are three cases: 1) depth is set on the bin, 2) depth is set on the dataset, and 3) depth is NaN.

if item['depth'] is not None:
add('depth')
elif dataset_depth is not None:
r['depth'].append(dataset_depth)
else:
r['depth'].append(np.nan)

@joefutrelle
Copy link
Contributor Author

joefutrelle commented Oct 5, 2023

This code may be relevant as well, since it's used in metadata upload and relies on pd.isnull.

def get_cell(named_tup, key):
val = getattr(named_tup, key)
try:
if pd.isnull(val):
return None
else:
return val
except TypeError:
return val

@joefutrelle joefutrelle added this to the v4.2 milestone May 29, 2024
@mike-kaimika
Copy link
Collaborator

@joefutrelle On the master branch, I'm not seeing things as outline in the original description here. I have a dataset where a few of the bins do not have depths set, and the value that comes out in the CSV file is an empty string, rather than a zero. Is that the expected outcome of this ticket (in which case, no changes are needed)?

My other thought would be that you might want an explicit NaN value in the CSV - we can do that with an argument to represent NaN values with some other string:
df.to_csv(csv_buf, mode='wb', na_rep='NaN', **kw)

However, should that affect other columns besides depth as well? For example, the above change worked on the depth column, but you can see it also produced NaN values for latitude, longitude an some other columns as well
image

@joefutrelle joefutrelle removed this from the v4.2 milestone Jul 30, 2024
@joefutrelle
Copy link
Contributor Author

I'm removing this from 4.2 until we can do more investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants