如何从熊猫系列中删除一个名字

时间:2019-11-26 17:40:09

标签: pandas series

我有两个系列的熊猫,并想用这两个系列做一个元组。我需要这样:

print(serie1,serie2)

sympathetic     0.074475
 healer          0.074475
 aaniye          0.074475
 dependable      0.074475
 companion       0.074475
 listener        0.074475
 athletic        0.074475
 exterminator    0.074475
 psychiatrist    0.074475
 pest            0.074475
 determined      0.074475
 chef            0.074475
 courageous      0.074475
 stylist         0.074475
 psychologist    0.074475
 organizer       0.074475
 pudunga         0.074475
 venaam          0.074475
 diwali          0.091250
 mornings        0.091250
 dtype: float64, 146tf150p    1.000000
 havent       1.000000
 home         1.000000
 okie         1.000000
 thanx        1.000000
 er           1.000000
 anything     1.000000
 lei          1.000000
 nite         1.000000
 yup          1.000000
 thank        1.000000
 ok           1.000000
 where        1.000000
 beerage      1.000000
 anytime      1.000000
 too          1.000000
 done         1.000000
 645          1.000000
 tick         0.980166
 blank        0.932702

我需要获得与上述相同的结果,但是我得到以下结果,该系列的名称为'tfidf':

(sympathetic     0.074475
 healer          0.074475
 aaniye          0.074475
 dependable      0.074475
 companion       0.074475
 listener        0.074475
 athletic        0.074475
 exterminator    0.074475
 psychiatrist    0.074475
 pest            0.074475
 determined      0.074475
 chef            0.074475
 courageous      0.074475
 stylist         0.074475
 psychologist    0.074475
 organizer       0.074475
 pudunga         0.074475
 venaam          0.074475
 diwali          0.091250
 mornings        0.091250
 Name: tfidf, dtype: float64, 146tf150p    1.000000
 yup          1.000000
 645          1.000000
 done         1.000000
 too          1.000000
 anytime      1.000000
 beerage      1.000000
 ok           1.000000
 thank        1.000000
 where        1.000000
 nite         1.000000
 lei          1.000000
 anything     1.000000
 er           1.000000
 thanx        1.000000
 okie         1.000000
 home         1.000000
 havent       1.000000
 tick         0.980166
 blank        0.932702
 Name: tfidf, dtype: float64)

如何删除名称为tf idf的名称,并根据第一个适合我的情况的示例显示它?

2 个答案:

答案 0 :(得分:1)

#The name of the index column of the series is deleted.
del series1.index.name
del series2.index.name

#The name of the series is omited
series1.name = series2.name = None

#This should return a tuple of two series
In:(series1, series2)


Out:(sympathetic     0.074475
 healer          0.074475
 aaniye          0.074475
 dependable      0.074475
 companion       0.074475
 listener        0.074475
 athletic        0.074475
 exterminator    0.074475
 psychiatrist    0.074475
 pest            0.074475
 determined      0.074475
 chef            0.074475
 courageous      0.074475
 stylist         0.074475
 psychologist    0.074475
 organizer       0.074475
 pudunga         0.074475
 venaam          0.074475
 diwali          0.091250
 mornings        0.091250
 dtype: float64, 146tf150p    1.000000
 yup          1.000000
 645          1.000000
 done         1.000000
 too          1.000000
 anytime      1.000000
 beerage      1.000000
 ok           1.000000
 thank        1.000000
 where        1.000000
 nite         1.000000
 lei          1.000000
 anything     1.000000
 er           1.000000
 thanx        1.000000
 okie         1.000000
 home         1.000000
 havent       1.000000
 tick         0.980166
 blank        0.932702
 dtype: float64)

答案 1 :(得分:0)

如果您不希望只打印dtype,而只打印值,则只需这样做

print(serie1.values, serie2.values)