dataframe查看某列值得种类
时间: 2023-11-18 21:16:05 浏览: 99
要查看DataFrame某列的所有唯一值的种类,可以使用pandas的unique()方法。
假设你的DataFrame名为df,要查看某列名为"column_name"的所有唯一值,可以使用以下代码:
df["column_name"].unique()
这将返回一个包含该列中所有唯一值的数组。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [大数据分析使用numpy在pandas dataframe上添加列](https://blog.csdn.net/yuuEva/article/details/109116832)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [如何根据列值从 DataFrame 中选择行?](https://blog.csdn.net/kalman2019/article/details/128428281)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文