How to realize Matrix Operation by Pandas
This article mainly shows you "Pandas how to achieve matrix operations", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Pandas how to achieve matrix operations" this article.
DataFrame.add (other, axis='columns', level=None, fill_value=None)
DataFrame.sub (other, axis='columns', level=None, fill_value=None)
DataFrame.mul (other, axis='columns', level=None, fill_value=None)
DataFrame.div (other, axis='columns', level=None, fill_value=None)
Parameters:
Other: sequence, data box, constant
Axis: {0,1, 'index',' columns'} 0 and index are horizontal operations, 1 and columns are vertical operations
Fill_value: None or floating point, replacing the default
Level: int or name, select a different index. There may be two indexes in a data box.
Return value:
Data frame
Import pandas as pddf = pd.DataFrame ([[1jre 1dje 1], [2pje 2je 2], [3pje 3je 3]], columns= ['Agar,' Bobby,'C']) print (df) A B C011 11 22 22 3 3 3print (df.sub ([1m 2J 3], axis=1)) A B C00-1-21 10-12 21 0print (df.sub) Axis=0) A, B, C, C, Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!