I have the following dataframe with a double index. How could I delete those rows where the first index is equal to the second index?
First_index Second_index Column
PitchAngle RotorSpeed -0.163742
GenSpeed PitchAngle -0.163689
GearboxBearingTemp PitchAngle -0.063614
GenSpeed GenSpeed 0.325689
AmbientTemperature AmbientTemperature 0.569469
WindDirection WindDirection -0.152658
Do the following:
Load modules
import io
import pandas as pd
Create the data
df = pd.read_csv(io.StringIO("""
First_index Second_index Column
PitchAngle RotorSpeed -0.163742
GenSpeed PitchAngle -0.163689
GearboxBearingTemp PitchAngle -0.063614
GenSpeed GenSpeed 0.325689
AmbientTemperature AmbientTemperature 0.569469
WindDirection WindDirection -0.152658
"""), sep="\s\s+", engine="python")
Do not select the rows where first index is equal to second index
df[~(df.First_index == df.Second_index)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.