Python df.
Understanding df. in Python
In Python, df is a variable name that refers to a DataFrame β a table-like structure provided by the pandas library.
When we use df. in a command, we are instructing Python to operate on that specific dataset.
Examples of df. Usage
| Command | Meaning |
|---|---|
df.head() |
Show the first 5 rows of the DataFrame |
df["tip"] |
Access the tip column |
df.tip |
Another way to access the tip column (only works if the name has no spaces) |
df.describe() |
Display summary statistics (mean, std, min, max, etc.) |
df.groupby("sex") |
Group the data by the sex column for analysis |
Summary
dfis the variable holding your table of data..allows you to apply methods or access columns from that DataFrame.- Itβs the standard way to work with data in pandas.