Skip to content

as_dataframe method fails #102

@tloubrieu-jpl

Description

@tloubrieu-jpl

Checked for duplicates

No - I haven't checked

🐛 Describe the bug

When I run this script:

from datetime import datetime
import pds.peppi as pep

# Create client connection to PDS Registry
client = pep.PDSRegistryClient()

# Define Apollo 12 PSE instrument URN
apollo12_pse_urn = "urn:nasa:pds:context:instrument:pse.a12a"

# Define your date range (March 25, 1970 to April 1, 1970)
start_date = datetime.fromisoformat("1970-03-25T00:00:00")
end_date = datetime.fromisoformat("1970-04-01T23:59:59")

# Query for Apollo 12 PSE data within that date range
apollo12_data = (
    pep.Products(client)
    .has_instrument(apollo12_pse_urn)
    .after(start_date)
    .before(end_date)
    .observationals()
)

# Convert to a pandas DataFrame to examine the results
# results_df = apollo12_data.as_dataframe()

With error:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/loubrieu/PycharmProjects/updart/tyler_test.py", line 24, in <module>
    results_df = apollo12_data.as_dataframe()
  File "/Users/loubrieu/PycharmProjects/updart/src/pds/peppi/query_builder.py", line 497, in as_dataframe
    need_dimension_reduction = df.apply(lambda x: len(x[column]) <= 1, axis=1)  # noqa
  File "/Users/loubrieu/PycharmProjects/updart/venv313/lib/python3.13/site-packages/pandas/core/frame.py", line 10374, in apply
    return op.apply().__finalize__(self, method="apply")
           ~~~~~~~~^^
  File "/Users/loubrieu/PycharmProjects/updart/venv313/lib/python3.13/site-packages/pandas/core/apply.py", line 916, in apply
    return self.apply_standard()
           ~~~~~~~~~~~~~~~~~~~^^
  File "/Users/loubrieu/PycharmProjects/updart/venv313/lib/python3.13/site-packages/pandas/core/apply.py", line 1063, in apply_standard
    results, res_index = self.apply_series_generator()
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/loubrieu/PycharmProjects/updart/venv313/lib/python3.13/site-packages/pandas/core/apply.py", line 1081, in apply_series_generator
    results[i] = self.func(v, *self.args, **self.kwargs)
                 ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/loubrieu/PycharmProjects/updart/src/pds/peppi/query_builder.py", line 497, in <lambda>
    need_dimension_reduction = df.apply(lambda x: len(x[column]) <= 1, axis=1)  # noqa
                                                  ~~~^^^^^^^^^^^
TypeError: object of type 'float' has no len()

🕵️ Expected behavior

I expected it to work.

📜 To Reproduce

...

🖥 Environment Info

  • Version of this software [e.g. vX.Y.Z]
  • Operating System: [e.g. MacOSX with Docker Desktop vX.Y]
    ...

📚 Version of Software Used

No response

🩺 Test Data / Additional context

No response

🦄 Related requirements

🦄 #xyz

⚙️ Engineering Details

No response

🎉 Integration & Test

No response

Metadata

Metadata

Assignees

Type

Projects

Status

🏁 Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions