-1

Hey guys I was wondering what exactly this code does, how does it iterate through the dataframe and what exactly does the lambda function do?

df.apply(lambda x: pd.Series(x.dropna().values))
Tasos K.
  • 7,979
  • 7
  • 39
  • 63
PRiiNT
  • 13
  • 2
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the [ask] page for help clarifying this question. – Hille Aug 25 '19 at 19:37

1 Answers1

0

The above block of code traverses the data frame column-wise and drops NA values. Lambda functions are the anonymous functions that are well explained in this text.

  • got that, thanks! What exactly is the purpose of the ".values" behind the dropna()? – PRiiNT Aug 25 '19 at 15:35
  • The ".values" is used to cast in the datatypes to accommodate the variability such as in case of dtypes that are float16 and float32, dtype will be upcast to float32, etc. – Gokul Krishnan R Aug 25 '19 at 16:03