回答編集履歴

1

追記

2022/08/15 06:54

投稿

meg_
meg_

スコア10600

test CHANGED
@@ -8,3 +8,28 @@
8
8
  > DataFrame with sorted values or None if inplace=True.
9
9
 
10
10
  [pandas.DataFrame.sort_values](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sort_values.html)
11
+
12
+ ---
13
+ 【質問者からのコメントを受けての追記】
14
+ ```Python
15
+ import pandas as pd
16
+ sales_list1=[["P001","iPhone 8 64GB",85000, 1],
17
+ ["P002","iPhone X 256GB",260000, 2],
18
+ ["P003","iPhone SE 32GB",37000, 1],
19
+ ["P002","iPhone X 256GB",130000, 1]]
20
+ columns1 =["Product ID","Product Name","Amount (JPY)", "Qty"]
21
+ df1=pd.DataFrame(data=sales_list1,columns=columns1)
22
+ print(df1)
23
+ # Product ID Product Name Amount (JPY) Qty
24
+ #0 P001 iPhone 8 64GB 85000 1
25
+ #1 P002 iPhone X 256GB 260000 2
26
+ #2 P003 iPhone SE 32GB 37000 1
27
+ #3 P002 iPhone X 256GB 130000 1
28
+ df1.sort_values(by="Amount (JPY)", inplace=True)
29
+ print(df1)
30
+ # Product ID Product Name Amount (JPY) Qty
31
+ #2 P003 iPhone SE 32GB 37000 1
32
+ #0 P001 iPhone 8 64GB 85000 1
33
+ #3 P002 iPhone X 256GB 130000 1
34
+ #1 P002 iPhone X 256GB 260000 2
35
+ ```