Summary of pandas error-prone points

1. When filtering according to multiple conditions, you should use & instead of and, such as:
lc.loc[(lc[“grade”] == “B”) & (lc[“loan_amnt”] > 5000)]
2. Single Before assigning series to series, you need to convert the data format, such as int, float, datetime
3. The difference between loc, iloc and ix is ​​that
loc takes the value according to the index name, such as:

import pandas as pd
data = [[1,2,3],[4,5,6]]
index = ['d','e']
columns=['a','b','c']
df = pd.DataFrame(data=data, index=index, columns=columns)
print df.loc['d']
'''
a    1
b    2
c    3
'''

Index a row and a column:

import pandas as pd  
data = [[1,2,3],[4,5,6]]  
index = ['d','e']  
columns=['a','b','c']  
df = pd.DataFrame(data=data, index=index, columns=columns)  
print df.loc['d',['b','c']]  
''''' 
b    2 
c    3 
'''  

iloc gets row data by row number, but not by row label index.
ix can be indexed either by line number or by line label.

updating……….

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325901079&siteId=291194637