带你一起盘点,Pandas1.0的主要功能( 五 )

\n
  • \n
  • >>> B =pd.Series([\"goodbye\" \"cruel\" \"world\"
    dtype=\"string\")>>> C = pd.Series([False True False
    dtype=\"bool\")>>> df.B = B df.C = C>>> df.info()<class 'pandas.core.frame.DataFrame'>RangeIndex: 3 entries 0 to 2Data columns (total 3 columns): #  Column  Non-Null Count  Dtype---  ------  --------------  ----- 0  A       3 non-null      int64 1  B       3 non-null      string 2  C       3 non-null      booldtypes: int64(1) object(1) string(1)memory usage: 200.0+ bytes

  • \n
    \n
    \n
  • 注意Dtype列现在如何反应新类型的string和bool 。  新字符串dtype最实用的优势在于 , 可以从DataFrame中选择string列 。 这样可以更快地仅对数据集的文本成分进行分析 。

  • \n
  • \n
  • df.select_dtypes(\"string\")

    推荐阅读