Skip to content

Instantly share code, notes, and snippets.

@devsjc
Created January 30, 2025 14:58
Show Gist options
  • Select an option

  • Save devsjc/c53475c71aaae59ed9cb6e9b4f16ab40 to your computer and use it in GitHub Desktop.

Select an option

Save devsjc/c53475c71aaae59ed9cb6e9b4f16ab40 to your computer and use it in GitHub Desktop.
Example of safer and more functional usage of the Pandas API
import pandas as py
df = (
pd
.read_csv("some-data.csv")
.rename(columns={"value":"x"})
.assign(new_col=lambda df: df["x"] * 2)
.loc[lambda df: df["y"] > 0.5]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment