One-liner. No transpose needed:
df.loc[~(df==0).all(axis=1)]
And for those who like symmetry, this also works…
df.loc[(df!=0).any(axis=1)]
More Related Contents:
- Delete a column from a Pandas DataFrame
- Calculate Time Difference Between Two Pandas Columns in Hours and Minutes
- What is the most efficient way to loop through dataframes with pandas?
- Pandas: Drop consecutive duplicates
- Split cell into multiple rows in pandas dataframe
- Handling Variable Number of Columns with Pandas – Python
- Pandas filling missing dates and values within group
- No module named ‘pandas._libs.tslibs.timedeltas’ in PyInstaller
- Use groupby in Pandas to count things in one column in comparison to another
- Reset color cycle in Matplotlib
- pandas unique values multiple columns
- Use index in pandas to plot data
- How to find which columns contain any NaN value in Pandas dataframe
- Python pandas: Keep selected column as DataFrame instead of Series
- Refresh Excel External Data with Python
- Pandas – dataframe groupby – how to get sum of multiple columns
- How to plot multiple dataframes to the same plot axes
- python pandas read_csv delimiter in column data
- Fixed effect in Pandas or Statsmodels
- Resample hourly TimeSeries with certain starting hour
- Pandas how to apply multiple functions to dataframe
- Select the max row per group – pandas performance issue
- Convert a Pandas DataFrame into a single row DataFrame
- How do I fill a column with one value in Pandas?
- Filtering pandas dataframe rows by contains str
- ValueError when using pandas.read_json
- Why does max() sometimes return nan and sometimes ignores it?
- How to fill the missing record of Pandas dataframe in pythonic way?
- Pandas analogue to SQL MINUS / EXCEPT operator, using multiple columns
- Pandas Groupby Agg Function Does Not Reduce