print(filtered_df[['job_location','experiences', 'education','company_type','co_experiments','salary_similarity','experiences','avg_high_salary', 'avg_low_salary','job_information' ]])如何使输出数据比较规整
时间: 2023-09-05 07:08:11 浏览: 56
你可以使用Pandas中的to_string()方法,该方法可以将DataFrame对象转换为字符串,并且可以设置输出格式,使输出数据比较规整。以下是一个示例:
```
print(filtered_df[['job_location', 'experiences', 'education', 'company_type', 'co_experiments', 'salary_similarity', 'experiences', 'avg_high_salary', 'avg_low_salary', 'job_information']].to_string(index=False, justify='center'))
```
在这个示例中,我们设置了to_string()方法的index参数为False,这将防止DataFrame对象的索引列被输出。我们还设置了justify参数为'center',这将使输出数据在每个单元格中居中对齐,从而使数据更加规整。
相关问题
filtered_df如果为series呢
如果 `filtered_df` 是一个 Series 而不是一个 DataFrame,你可以使用 `dropna()` 函数来删除 Series 中的 NaN 值。以下是一个示例:
```python
filtered_series = filtered_series.dropna()
```
这行代码将删除 `filtered_series` 中的所有 NaN 值。
请注意,Series 是一维的数据结构,而 DataFrame 是二维的数据结构。因此,删除 NaN 值的方法略有不同。
希望这次回答对你有帮助!如果还有其他问题,请随时提问。
filtered_predictions = np.array(filtered_predictions)
这行代码的作用是将`filtered_predictions`转换为numpy数组。`filtered_predictions`是一个列表,通过`np.array()`函数将其转换为numpy数组,可以方便地进行一些数值计算和处理。最终,转换后的numpy数组被赋值给`filtered_predictions`变量。