Pandas删除最后一行

来自YTYZX有图有真相的百科
Ytyzx讨论 | 贡献2022年8月27日 (六) 21:22的版本 (创建页面,内容为“import pandas as pd import numpy as np df = pd.DataFrame({ 'Quantity': { 0: 50, 1: 50, 2: 70, 3: 50, 4: 80, 5: 10...”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

import pandas as pd import numpy as np df = pd.DataFrame({

   'Quantity': {
       0: 50,
       1: 50,
       2: 70,
       3: 50,
       4: 80,
       5: 100,
       6: 30,
       7: 106
   },
   'Product_Names': {
       0: 'Mosuse',
       1: 'Keyboard',
       2: 'Headphones',
       3: 'CPU',
       4: 'Flash Drives',
       5: 'Tablets',
       6: 'Android Box',
       7: 'LCD'
   },
   'Product_Prices': {
       0: 100,
       1: 70,
       2: 150,
       3: 1500,
       4: 70,
       5: 1700,
       6: 2500,
       7: 1600
   },

})


df.drop([len(df)-1],inplace=True) #请勿使用df.drop([-1],inplace=True) print("df",df)