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:
206
206
dfa.A
207
207
panel.one
208
208
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.
210
212
211
213
.. ipython :: python
212
214
213
215
sa.a = 5
214
216
sa
215
- dfa.A = list (range (len (dfa.index)))
217
+ dfa.A = list (range (len (dfa.index))) # ok if A already exists
216
218
dfa
217
-
219
+ dfa[' A' ] = list (range (len (dfa.index))) # use this form to create a new column
220
+ dfa
221
+
218
222
.. warning ::
219
223
220
224
- 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