File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -206,15 +206,19 @@ as an attribute:
206206 dfa.A
207207 panel.one
208208
209- Setting is allowed as well
209+ You can use attribute access to modify an existing element of a Series or column of a DataFrame, but be careful;
210+ if you try to use attribute access to create a new column, it fails silently, creating a new attribute rather than a
211+ new column.
210212
211213.. ipython :: python
212214
213215 sa.a = 5
214216 sa
215- dfa.A = list (range (len (dfa.index)))
217+ dfa.A = list (range (len (dfa.index))) # ok if A already exists
216218 dfa
217-
219+ dfa[' A' ] = list (range (len (dfa.index))) # use this form to create a new column
220+ dfa
221+
218222 .. warning ::
219223
220224 - You can use this access only if the index element is a valid python identifier, e.g. ``s.1 `` is not allowed.
You can’t perform that action at this time.
0 commit comments