frbcat icon indicating copy to clipboard operation
frbcat copied to clipboard

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

Open InesPM opened this issue 2 years ago • 2 comments

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

InesPM avatar May 24 '23 16:05 InesPM

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 avatar Jun 01 '23 15:06 davidgardenier

PS Have a look at issue #14

davidgardenier avatar Jun 01 '23 15:06 davidgardenier