Dotted notation retrieves a pandas DataFrame column with an expression such as df.colname. It is concise and readable, but works only when the label is a valid Python identifier and does not conflict with an attribute. section 2.0
Retrieve a column
For a DataFrame with a column named population, use df.population. Prefer df['population'] when the label contains spaces or other invalid identifier characters, or when attribute-versus-column meaning could be unclear. section 2.0
Keep these distinctions in mind:
- Use df['x'] to request a column named x; use df.loc['x'] or df.iloc[0] to retrieve a row when x is an index label or positional target. section 2.0
- Treat dotted notation as a convenience rather than a universal replacement for bracket notation. section 2.0








