i have a pandas dataframe with index which are datetime. I want to change the index such…
- User
i have a pandas dataframe with index which are datetime. I want to change the index such that the new index is the number of business days between the index value and a specified date
- Assistant
To achieve this, you can use the Pandas
bdate_rangefunction to calculate the number of business days between each index date and a specified date. Here's a step-by-step guide on how to do it:-
First, make sure you have the necessary pandas library imported:
pythonimport pandas as pd
-
- User
this is my current q query:
query_bond_feed = f""" select last midYield by sym, 0D02:00 xbar time from EGBBondFeed where date in {dates_str}, time within(06:00:00; 16:00:00), sym = `{isin1} """
how do you change it such that it queries where sym is in the list of variables: isin1, isin2
- Assistant
To modify your query to filter for multiple symbols contained in a list (e.g.,
isin1,isin2), you'll need to alter the condition that checks forsym. Instead of checking equality with a single value, you can use theinkeyword within the query to check ifsymis in a list of values.Here's how you can adjust your query to accommodate multiple symbols:
Assuming
isin1andisin2are Python variables containing the identifiers you're interested in, you can create a list of these variables and then format them into your query.python