Ben Chuanlong Du's Blog

It is never too late to learn.

`ifelse` on Pandas Series

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Series.apply + Lambda Function

DataFrame.apply + Lambda Function

axis=1: apply the lambda function on each row

List Comprehension

numpy.where

numpy.where is vectorized ifelse.

Get Location of Max Value in a Pandas Series

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

idxmax Return the row label of the maximum value.

argmax: Return int position of the largest value in the Series.

Polars Series in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Understand Index in pandas

Comments

  1. There are multiple ways to update the index of a DataFrame or Series. First, you can assign a new Series or Index object to the index of a DataFrame or Series. Or you can use methods such as DataFrame.set_index or DataFrame.reset_index. DataFrame.reset_index resets the index of a DataFrame/Series to an integer index starting from 0. The old index is kept by default but can be dropped using the option drop=True