pandas中类似SQL的语句?

时间:2015-11-05 17:10:18

标签: python sql pandas dataframe

我试图在pandas中运行以下SQL语句(显然是在Python代码中),但我无处可去:

select year, contraction, indiv_count, total_words from dataframe
    where contraction in ("i'm","we're","we've","it's","they're")

其中contractionscharyearindiv_counttotal_wordsint

我对大熊猫不太熟悉。如何在Python中创建类似的语句?

1 个答案:

答案 0 :(得分:2)

如果您还没有,我建议您阅读Anton评论中列出的文档,但是它缺少public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button_frm2(object sender, EventArgs e) { Form1 frm1 = new Form1(); textBox1.Text= frm1.dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); } } 方法的文档,这是您需要复制的方法SQL .isin()

in

然后可以使用df[df['contraction'].isin(["i'm","we're","we've","it's","they're"])] 或者您最喜欢的方法获取列选择(有很多)。