Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSP_Rank/remove_rows_with_no_consensus.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (13 sloc)
574 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def remove_missing_values(input_csv, output_csv, column_name): | |
# Read the CSV file into a DataFrame | |
df = pd.read_csv(input_csv) | |
# Remove rows with missing values in the specified column | |
df_cleaned = df.dropna(subset=[column_name]) | |
# Save the cleaned DataFrame back to a CSV file | |
df_cleaned.to_csv(output_csv, index=False) | |
# Example usage | |
input_csv = './CSP_Rank_Scores/CSP_7jq8_CSpred.csv' | |
output_csv = input_csv[:-4] + "_clean.csv" | |
column_name = 'consensus' | |
remove_missing_values(input_csv, output_csv, column_name) |