frbcat
frbcat copied to clipboard
TNS: 'DataFrame' object has no attribute 'burst_bandwidth'
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
Hi Ines,
I suspect this should be a fairly easy issue to solve. I would suggest tackle it in the following way:
- Make a local clone of this repo
- Test downloading TNS entries using the local files. I would suspect this will fail given the error you posted.
- 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.
- 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.
- 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! : )
PS Have a look at issue #14