Python Pandas拉行列表,其中空行在一列中

时间:2017-09-15 18:55:17

标签: python pandas filter nan

我正在使用更大的数据帧df。

df的第一列是Customer_ID。然后是大约50列。

当我转动这个数据框时,我会得到这样的结果:

pv1 = pd.pivot_table(df,index=["Customer_ID","Category"],values=["Sales"],aggfunc=np.sum)

pv1.head()

Customer ID | Category | Sales
123           A           345345
              B           6736
345           A           982764

似乎客户ID列中有空格(请参阅第2行)。

我尝试使用以下语句提取这些行的列表:

df.loc[df['Customer_ID'] == ' ']

但我没有结果。

0 个答案:

没有答案