我不明白pandas DataFrame filter.
import pandas as pd
df = pd.DataFrame(
[
['Hello', 'World'],
['Just', 'Wanted'],
['To', 'Say'],
['I\'m', 'Tired']
]
)
Run Code Online (Sandbox Code Playgroud)
df.filter([0], regex=r'(Hel|Just)', axis=0)
Run Code Online (Sandbox Code Playgroud)
我希望[0]将第一列指定为要查看的列并axis=0指定过滤行.我得到的是这个:
0 1
0 Hello World
Run Code Online (Sandbox Code Playgroud)
我在期待
0 1
0 Hello World
1 Just Wanted
Run Code Online (Sandbox Code Playgroud)