Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Pandas drop empty rows

import pandas as pd


# Create a Dataframe from a CSV
df = pd.read_csv('example.csv')

# Drop rows with any empty cells
df.dropna(
    axis=0,
    how='any',
    thresh=None,
    subset=None,
    inplace=True
)
Comment

pandas drop rows with empty list

# Drop all rows that have an empty list in "example_column"

df[df['example_column'].map(lambda d: len(d)) > 0]
Comment

PREVIOUS NEXT
Code Example
Python :: how to move columns in a dataframen in python 
Python :: leap year algorithm 
Python :: start new app in django 
Python :: python writelines newline 
Python :: pandas plot distribution 
Python :: python tqdm while loop 
Python :: telnet via jump host using python 
Python :: python r before string 
Python :: button in flask 
Python :: from time import sleep, time 
Python :: how to get the year in python 
Python :: convert period to timestamp pandas 
Python :: discord.py how to give a user a role 
Python :: opencv save image rgb 
Python :: pandas scatter plot with different colors 
Python :: python reverse string 
Python :: drop na in pandas 
Python :: python gtts 
Python :: loop through 2 dataframes at once 
Python :: codeforces 677a solution 
Python :: random string generator python 
Python :: b1-motion tkinter 
Python :: python - count number of values without dupicalte in a second column values 
Python :: nested dict to df 
Python :: check if number in range 
Python :: how to record pyttsx3 file using python 
Python :: download pdf using python 
Python :: python print no end of line 
Python :: panda datetime ymd to dmy 
Python :: jupyter notebook set default directory 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =