Issue
I have a column with consecutive digits in a Pandas DataFrame.
A
1
2
3
4
I would like to change all those values to a simple string, say "foo", resulting in
A
foo
foo
foo
foo
Solution
Just select the column and assign like normal:
In [194]:
df['A'] = 'foo'
df
Out[194]:
A
0 foo
1 foo
2 foo
3 foo
Assigning a scalar value will set all the rows to the same scalar value
Answered By - EdChum
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.