Once, when processing data, I wanted to remove the row with the specified column value in the DataFrame with empty values. I adopted the following method, but it was not successful:
# encoding: utf-8 import pandas as pd import math import numpy as np data = pd.read_csv('') print len(data) for i in range(len(data)): if (data['director'][i] == ‘'): data = (i) data.to_csv('')
Then I found that to remove the row with the value of the specified column in DataFrame with empty values, you can use numpy or isnan() in math to determine the method in the loop:
# encoding: utf-8 import pandas as pd import math import numpy as np data = pd.read_csv('') print len(data) for i in range(len(data)): if (data['director'][i]): data = (i) data.to_csv('')
The above method of removing the specified column as empty rows in the DataFrame is all the content I share with you. I hope you can give you a reference and I hope you can support me more.