I have a DataFrame named "returns" that has a column 'permno'. The code 15372.0 in returns['permno']
returns True, telling me that 15372.0 is in the column 'permno'. However, returns[returns['permno']==15372.0]
returns an empty Series, suggesting that it cannot find any values in the DataFrame where the permno is 15372.0. Similarly, I have a column 'dlycaldt' that stores dates as strings; the code '2021-01-04' in returns['dlycaldt']
returns False, but the code returns[returns['dlycaldt']=='2021-01-04']
returns a large DataFrame. Can someone help me reconcile these results?
I wrote the following code snippet to find if 15372.0 was really in the DataFrame or not:
is_present = returns['permno'].isin([15372.0])
if is_present.any():
print("At least one row has the value 15372.0 in the 'permno' column.")
else:
print("No rows have the value 15372.0 in the 'permno' column.")
Running this code told me that no rows have the value 15372.0. If this is the case, how come the initial line of code is returning True?