简体   繁体   English

如何在列中创建一个包含多个值的表

[英]How to create a table of more than one value in column

I have a pandas dataframe in python with multiple columns. 我在python中有一个带有多列的pandas数据框。 I can create another list of a certain value in a specific column, but how do I do multiple values within the same column? 我可以在特定列中创建另一个具有特定值的列表,但是如何在同一列中创建多个值?

Here is my code to display the list for only RB: 这是我的代码,仅显示RB的列表:

NewTable=Football[Football.Position=='RB']

However I want RB and WR. 但是我想要RB和WR。 How should I modify my code? 我应该如何修改我的代码?

First off i'll say that to make the code more pythonic you should ditch the CamelCase variables! 首先,我要说的是,要使代码更具pythonic性,您应该放弃CamelCase变量! Secondly the question is kind of hard to decipher, if I understand correctly then this should help... 其次,这个问题很难解读,如果我理解正确的话,那应该会有所帮助...

new_table = football[ (football.position == 'RB') & (football.position == ''WR')]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果 dataframe 中的列具有多个值,则创建多行 - create multiple rows if a column has more than one value in a dataframe 有没有办法在表的同一列中过滤多个值? - Is there a way to filter for more than one value in the same column of a table? 对于 pandas,如何使用多列创建平均出现次数表? - With pandas, how to create a table of average ocurrences, using more than one column? 如果每列每行有多个值,如何在熊猫数据框中的两列之间创建字典? - How can I create a dictionary between two columns within a pandas dataframe if each column has more than one value per row? 如何检查一列中的值是否可以包含多于另一列中的值 - How to check if a value in one column can contain more than value in another column 从 dataframe 列创建一个字典,该列在其单元格中有多个值 - Create a dictionary from dataframe column which has more than one value in its cell 熊猫如何聚合多个列 - Pandas how to aggregate more than one column 如何在熊猫数据框中找到与另一列中的多个值相对应的列中具有值的所有行? - How can I find all rows with a value in one column which corresponds to more than one value in another column in a pandas dataframe? Python:如何在for中解压多个值? - Python: how to unpack more than one value in a for? 如何在Django中注释多个值 - How to annotate more than one value in Django
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM