i have this dataframe in pandas:
df = pd.DataFrame(
{"bond": ["XSD070623A17","XSD090222A10","XSD100221A18", "XSD070623T15",
"XSD070623T23","XSD090222T32","XSD100221T11"],
"issue_date":["01.01.2020", "03.05.2020", "05.02.2020", "10.11.2019",
"01.01.2020", "03.05.2020", "12.10.2020"]
}
)
df
bond issue_date
0 XSD070623A17 01.01.2020
1 XSD090222A10 03.05.2020
2 XSD100221A18 05.02.2020
3 XSD070623T15 10.11.2019
4 XSD070623T23 01.01.2020
5 XSD090222T32 03.05.2020
6 XSD100221T11 12.10.2020
As you see, the first 9 characters of the some values are same in the "bond" column. i will get a subset of this dataframe that for every value whose 10th character is equal "A", i wanna get the value which has same the first 9 characters and 10th character is equal "T". After that if issue date of "A" and "T" bonds are different then i wanna filter both of these bonds.
e.g. bond value of 0th index has same pattern with values of 3rd and 4th indexes but issue date of 0th and 4th indexes are same, so i wanna filter 0th and 3rd rows. On the other hand bond value of 1st index has same pattern with 5th index, but their issue dates are same so i wanna filter none of them.
After all, i wanna get the following dataframe:
bond issue_date
0 XSD070623A17 01.01.2020
2 XSD100221A18 05.02.2020
3 XSD070623T15 10.11.2019
6 XSD100221T11 12.10.2020
Any help will be appreciated.