简体   繁体   中英

Efficient way to read non-empty cells in a column in CSV file

I have a large python file (>500,000 rows), and would like to read non-empty cells in a column in the dataframe (panda). Right now, I am doing this:

df = pd.read_csv(filename)

myiter = []    

    for xiter, x in enumerate(df['Column_name']):

        if (np.isnan(x) == False):
            myiter.append(xiter)

Is there a more efficient way to do the same?

are they tagged as NaN in your df ?

if yes then do

df.dropna()

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM