We can delete the rows containing more than one non-missing value as follows:
main.py347 chars12 lines
This code creates a DataFrame with 4 rows and 3 columns, where some of the values are missing. Then, it counts the number of non-missing values in each row and appends a new column 'non_missing' to the DataFrame. Finally, it selects only the rows where the 'non_missing' column is less than or equal to 1 and drops the temporary column.
The resulting output will be:
main.py51 chars4 lines
Note that this approach assumes that only numerical values are missing in the DataFrame. If there are other types of missing values, they may not be counted as such.
gistlibby LogSnag