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

TNS: 'DataFrame' object has no attribute 'burst_bandwidth' #16

Open
InesPM opened this issue May 24, 2023 · 2 comments
Open

TNS: 'DataFrame' object has no attribute 'burst_bandwidth' #16

InesPM opened this issue May 24, 2023 · 2 comments

Comments

@InesPM
Copy link
Contributor

InesPM commented May 24, 2023

When running the following command (where user and id are my personal TNS login details):
tns = TNS(tns_name="user", tns_id="id", repeaters=False)
I get the following Attribute error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-e98b701f8d56> in <module>
----> 1 tns = TNS(tns_name="MyName", tns_id="MyID", repeaters=False)

/opt/anaconda3/lib/python3.9/site-packages/frbcat/tns.py in __init__(self, oneoffs, repeaters, repeat_bursts, update, path, save, mute, tns_id, tns_name)
     52         self.tns_name = tns_name
     53 
---> 54         self.get_data()
     55         self.filter(one_offs=self.oneoffs,
     56                     repeaters=self.repeaters,

/opt/anaconda3/lib/python3.9/site-packages/frbcat/tns.py in get_data(self)
    125                 entries = self.get_json()
    126                 df = self.json2df(entries)
--> 127                 self.clean_df(df)
    128 
    129                 if self.save:

/opt/anaconda3/lib/python3.9/site-packages/frbcat/tns.py in clean_df(self, df)
    365             df[c + '_err'] = err.astype(float)
    366 
--> 367         cols = df.burst_bandwidth.str.strip(' MHz').str.partition(' (')[[0, 2]]
    368         df['burst_bandwidth'] = cols[0].astype(float)
    369         err = cols[2].str.strip(')')

/opt/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5573         ):
   5574             return self[name]
-> 5575         return object.__getattribute__(self, name)
   5576 
   5577     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'burst_bandwidth'

Could it be that I have an uncompatible pandas version? I currently have version 1.4.4

@davidgardenier
Copy link
Collaborator

Hi Ines,

I suspect this should be a fairly easy issue to solve. I would suggest tackle it in the following way:

  1. Make a local clone of this repo
  2. Test downloading TNS entries using the local files. I would suspect this will fail given the error you posted.
  3. In an IDE like vscode, add a breakpoint just before the bug occurs (line 367 of tns.py by the looks of it), then try running your download test in the debugging mode. It should pause before the bug, allowing you to look at the variables prior to this.
  4. Come up with a fix, and then make a pull request (this would be an excellent easy way to try if you've never do so before). Pull requests are the bread and butter of programming, so well worth learning.
  5. Leon set up the repo nicely so that your fix (if we approve it) will automatically be pushed to the python repository so that you can update your frbcat version via pip, and have everything running again!

I highly doubt the issue is to do with your pandas version, but I suspect it's down to a change in how TNS serves its data.

Good luck saving frbcat! : )

@davidgardenier
Copy link
Collaborator

PS Have a look at issue #14

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