Python Error: save is not part of the public api writer.save()
I have the Python code, that extracts my account balance from Binance, and save it to Excel file. When I run it on a local PC, the code executes just fine. But when I run it in Linode, I get the following error:
Future warning: save is not part of the public api
writer.save()
What to do to avoid this error?
Here is the code sample:
>
import pandas as pd, openpyxl
import datetime as dt
client = Client (key, secret)
from binance.client import Client
from binance.enums import *
account_summary = client.get_account()
account_balance = account_summary ["balances"]
df_balance = pd.DataFrame(account_balance)
df_balance.free = round(df_balance.free.astype(float),3)
df_balance.locked = round(df_balance.locked.astype(float),3)
time_pinged = pd.Series(dt.datetime.now())
df_balance['time_pinged'] = dt.datetime.utcnow().strftime('%Y-%m-%d %H-%M-%S.%f')[:-7]
condition = (df_balance["free"]>0) | (df_balance["locked"]>0)
money_balance = df_balance.loc[condition]
#print (money_balance)
writer = pd.ExcelWriter('Binance_account.xlsx', engine='openpyxl', mode='a', if_sheet_exists='overlay')
df_balance.to_excel(writer, trading_symbol, index = False)
money_balance.to_excel(writer, 'money_balance', index = False, startrow=writer.sheets['money_balance'].max_row, header=None)
writer.save()
print ('Exported to Excel succesfully')
1 Reply
What to do to avoid this error?
Use only methods on the pd.ExcelWriter object that are documented as public…that's what I inferred from the error message…
Alternatively, you could be using an outdated version of panda… The method may be part of the public interface in the newer version. I don't know. That's not to say that writer.save() doesn't exist in the old version…it could be called something else.
The fact that it works one place and not there other indicates to me that the version in the place where it doesn't work is not current. Look for version mismatches between the two platforms and correct it (beware this might break something else!).
Caveat…if your code is running as part of the browser process on your PC and trying to save to a remote file, that's a no-no.
-- sw