我想获取包含所有带有 2 个空格的行的数据框列的列表。
输入:
import pandas as pd
import numpy as np
pd.options.display.max_columns = None
pd.options.display.max_rows = None
pd.options.display.expand_frame_repr = False
df = pd.DataFrame({'id': [101, 102, 103],
'full_name': ['John Brown', 'Bob Smith', 'Michael Smith'],
'comment_1': ['one two', 'qw er ty', 'one space'],
'comment_2': ['ab xfd xsxws', 'dsd sdd dwde', 'wdwd ofjpoej oihoe'],
'comment_3': ['ckdf cenfw cd', 'cewfwf wefep lwcpem', np.nan],
'birth_year': [1960, 1970, 1970]})
print(df)
Run Code Online (Sandbox Code Playgroud)
输出:
id full_name comment_1 comment_2 comment_3 birth_year
0 101 John Brown one two ab xfd …Run Code Online (Sandbox Code Playgroud)