Is it possible to Skip Blank Lines in a Dataframe? If Yes then how I can do this

A.Code.1

I am trying to run this code

num = df_out.drop_duplicates(subset=['Name', 'No.']).groupby.(['Name']).size()

But when I do I get this error:

ValueError: not enough values to unpack (expected 2, got 0)

If we think about my dataframe(df_out) as an excel file I do have blank cells but no full column or full row is blank. I needed to skip the blank lines to run the code without changing the dataframe's structure.

Is this possible?

Thank you

Guybrush

Consider using df.dropna(). It is uses to remove rows that contains NA. See https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dropna.html for more information.

At first, you probably want your "blank cells" to be converted to NA value, so they can be dropped by dropna(). This can be done using various methods, notably df.replace(r'\s+', pandas.np.nan, regex=True). If your "blank cells" are all empty strings, or fixed strings equal to some value s, you can directly use (first case) df.replace('', pandas.np.nan) or (second case) df.replace(s, pandas.np.nan).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I delete blank lines in a file?

Is it possible to enforce tagging rules with QAF BDD, if yes how can i do it?

How can I split this dataframe by blank spaces?

how can I leave blank lines between outputs of echo?

How can I insert BLANK lines between lists in BitBucket Markdown?

How do I remove blank lines from a string in Python?

How do I split a text file into an array by blank lines?

VSCode: How do I KEEP blank lines (in scss files or others)?

How Do I Ignore Blank Lines Processing a CSV File In Clojure?

How do I remove blank lines from files?

How do I make an Excel formula return Yes or No based on conditions AND nothing when blank

how to skip lines in pandas dataframe at the end of the xls

How to skip blank lines in CSV using FlatFileItemReader and chunks

How can I increment by 1 the amount of lines I want to skip in a batch file?

How can I do this in mongodb? Is that possible?

How can I mark something as ‘yes’ or ‘no’ based on when two cells match as well as whether another cell is blank — in Numbers

How to skip first, last non-blank line and blank lines from modification in a file?

How do I skip certain lines of code to move back up in a while loop?

How can i skip "undefined"?

how do i plot multiple lines using value counts on a dataframe

Can I set the access tier when I upload a blob? If yes, then how to do that?

How can I do dataframe subtraction?

In pycharm, how can I specify "blank lines before" a class method? (coding style)

How can I use sed to display the lines between the first blank line and the last line?

How can I format a txt file in python so that extra paragraph lines are removed as well as extra blank spaces?

bash, using here document, how can I read multiple lines of user input, stop on blank line

When using openrowset how can I avoid inserting blank lines at the end of an excel sheet

How can I prevent blank lines from being counted in line numbers in Latex?

How do I parse through java source code and not store blank lines?