I have a data frame looking like below.
INPUT
col1
0 something1
1 xyz
2 something1
3 abc
4 something1
5 xyz
6 something1
7 xyz
OUTPUT
col1
0 something1
4 something1
6 something1
Create a new subset of your df filtering the value you want on col1
df_output = df[df['col1']== 'something1']
or if you want just a df with values grouped ie sorted then
data = {'col':["something1"
, "something2"
, "something1"
, "something3"
, "something1"
, "something2"
, "something1"
,"something2"]}
df = pd.DataFrame(data)
df.sort_values(by='col')
col
0 something1
2 something1
4 something1
6 something1
1 something2
5 something2
7 something2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.