Skip to content

print df.ix[..,..] changes dataframe? #5424

Closed
@jankatins

Description

@jankatins

These two codeblocks result in different dataframes:

import pandas as pd
import numpy as np
cont = ['one', 'two','three', 'four', 'five', 'six', 'seven']
dfb = pd.DataFrame({'a' : cont, "b":cont[3:]+cont[:3] ,'c' : np.arange(7)})
#print dfb.ix[0,"c"]
dfb.ix[7,'c'] = 1
print dfb
print dfb.ix[7,"c"]
print dfb.ix[0,"c"]

       a      b  c
0    one   four  0
1    two   five  1
2  three    six  2
3   four  seven  3
4   five    one  4
5    six    two  5
6  seven  three  6
7    NaN    NaN  1
1.0
0.0

and

import pandas as pd
import numpy as np
cont = ['one', 'two','three', 'four', 'five', 'six', 'seven']
dfb = pd.DataFrame({'a' : cont, "b":cont[3:]+cont[:3] ,'c' : np.arange(7)})
print dfb.ix[0,"c"]
dfb.ix[7,'c'] = 1
print dfb
print dfb.ix[7,"c"]
print dfb.ix[0,"c"]

0
       a      b   c
0    one   four   0
1    two   five   1
2  three    six   2
3   four  seven   3
4   five    one   4
5    six    two   5
6  seven  three   6
7    NaN    NaN NaN
nan
0.0

pd.version = '0.12.0-922-gac1609e'

In the first case I also don't understand why the last column is changed to a float when I set an int.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions