'How to improve the given line of code while filtering pandas dataframe?
The below line of code was to filter a dataframe. I would like to know how to improve this line of code
T1_df = df2[((df2['Azimuth'] > (df2['Sim_Az'] - 1)) & (df2['Azimuth'] < (df2['Sim_Az'] + 1)))]
T1_df = T1_df[((T1_df['Elevation'] > (T1_df['Sim_EL'] - 1)) & (T1_df['Elevation'] < (T1_df['Sim_EL'] + 1)))]
T1_df = T1_df[((T1_df['RadVel'] > (T1_df['Sim_velocity'] - 1)) & (T1_df['RadVel'] < (T1_df['Sim_velocity'] + 1)))]
T1_df = T1_df[((T1_df['Cross_Sec'] > (T1_df['Sim_rcs'] - 1)) & (T1_df['Cross_Sec'] < (T1_df['Sim_rcs'] + 1)))]
T1_df = T1_df[((T1_df['Distance'] > (T1_df['Sim_distance'] - 1)) & (T1_df['Distance'] < (T1_df['Sim_distance'] + 1)))]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
