在Pandas中按行值排序和列出

时间:2017-12-16 02:42:42

标签: pandas

我通过阅读包含两个字段" word"的csv文件创建了一个df。和" TAG"。

import pandas as pd
df = pd.read_csv("Book2.csv")
print df

Output
       WORD    TAG
0     This     DET
1       is    VERB
2        a     DET
3    sample   NOUN
4  sentence   NOUN
5        to   PART
6     check   VERB
7      NLP   PROPN
8        in    ADP
9    python   NOUN

我想提取所有名词和动词以及类似的其他标签和相应的单词并创建一个新的df。

预期产出:

NOUN           VERB
Sample          is
sentence        check
python 

我是熊猫的新手。请帮忙。

1 个答案:

答案 0 :(得分:3)

使用#include <initializer_list> template <typename T, std::size_t> using typer = T; template <typename T, std::size_t N = 64U, typename = std::make_index_sequence<N>> struct proBar; template <typename T, std::size_t N, std::size_t... Is> struct proBar<T, N, std::index_sequence<Is...>> : public proBar<T, N-1U> { using proBar<T, N-1U>::bar; void bar (typer<T, Is>... ts) { } }; template <typename T> struct proBar<T, 0U, std::index_sequence<>> { void bar () { } }; template <typename T> struct foo : public proBar<foo<T>> { using proBar<foo<T>>::bar; foo (std::initializer_list<T>) { } template <typename Compare> auto bar (foo &, Compare comp) -> decltype(comp(T(), T()), void()) { bool b = comp(T(), T()); } }; int main() { foo<int> f = {1, 2, 3}; f.bar({4, 5, 6}); f.bar(f, f); f.bar(f, {4, 5, 6}); // now compile }

  CustomCellView.swift

  10 myLabel.isUserInteractionEnabled = true
  11 let tap = UITapGestureRecognizer(target: self, action: #selector(tapLabelGesture))
  12 myLabel.addGestureRecognizer(tap)

  13 func tapLabelGesture() {
  14   print("Clicked on Label ")
       let url="www.google.com"
  15   let activityVC = UIActivityViewController(activityItems: [url], applicationActivities: nil)

  16   activityVC.popoverPresentationController?.sourceView = self.view
  17   self.present(activityVC, animated: true, completion: nil)
  18 }

如果你想'删除'NaN

groupby