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

Warning: Pandas Concat Empty DataFrame #32

Open
apalacio9502 opened this issue Nov 16, 2023 · 6 comments
Open

Warning: Pandas Concat Empty DataFrame #32

apalacio9502 opened this issue Nov 16, 2023 · 6 comments

Comments

@apalacio9502
Copy link

Hello,

We are encountering this warning with BDH when some of the queried tickers have no information, how can we suppress it.

FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.

Regards,

@apalacio9502 apalacio9502 changed the title Pandas Concat Empty DataFrame Warning Warning: Pandas Concat Empty DataFrame Nov 16, 2023
@avantgardeam
Copy link
Contributor

Hello,

Could you provide a minimal reproducible example of the query causing the error?

@mmtpo
Copy link

mmtpo commented Feb 9, 2024

I've been enjoying using your wrapper for blpapi. Recently, I encountered the same FutureWarning when using bdh function. Here is a min reprex:

Environment

  • Python version: 3.10.9
  • blp version: 0.0.3
  • blpapi version: 3.23.1
  • pandas version: 2.1.4

Reproducible Example

from blp import blp
bquery = blp.BlpQuery().start()

bquery.bdh(
    ["CZTA3MAY Index", "GTCZK2Y Govt"],
    ["PX_LAST"],
    start_date="20240208",
    end_date="20240208"
)

@slmg
Copy link

slmg commented Feb 29, 2024

Hi, based on this SO thread, the below should silence this warning.

pandas.concat(dfs)

changed to

pandas.concat([df for df in dfs if not df.empty]) 

@matthewgilbert
Copy link
Owner

Happy to take a PR on this.

Can someone post what the actual response from @mmtpo looks like? Ideally raw blpapi output and the parsed dataframe. Don't currently have access to a bbg connection.

@mmtpo
Copy link

mmtpo commented Feb 29, 2024

Sure! The problem should be as mentioned by @simg, i.e. the first response returns empty data, hence resulting in an DataFrame with no rows causing the warning. See partial dumps of the responses for both securities and the given date as above:

'HistoricalDataResponse':
{'securityData': {'security': 'CZTA3MAY Index', 'eidData': [...], 'sequenceNumber': 0, 'fieldExceptions': [...], 'fieldData': [...]}}
{'security': 'CZTA3MAY Index', 'eidData': [], 'sequenceNumber': 0, 'fieldExceptions': [], 'fieldData': []}
{'fieldData':[]}
...

'HistoricalDataResponse':
{'securityData': {'security': 'GTCZK2Y Govt', 'eidData': [...], 'sequenceNumber': 1, 'fieldExceptions': [...], 'fieldData': [...]}}
{'security': 'GTCZK2Y Govt', 'eidData': [], 'sequenceNumber': 1, 'fieldExceptions': [], 'fieldData': [{...}]}
{'fieldData': {'date': Timestamp('2024-02-0...00:00:00'), 'PX_LAST': 3.828}}

@simg
Copy link

simg commented Feb 29, 2024

The problem should be as mentioned by @simg @slmg

FTFY :)

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

6 participants