I have output that looks like this:
JavaScript
x
15
15
1
nutrition_info_256174499 = df1.loc[:"Salt" , "%Reference Intake*"]
2
3
print (nutrition_info_256174499)
4
5
Typical Values
6
Energy 5%
7
Fat 1%
8
of which saturates 1%
9
Carbohydrates 7%
10
of which sugars 2%
11
Fibre -
12
Protein 7%
13
Salt 6%
14
Name: %Reference Intake*, dtype: object
15
What must be done to remove both Name and dtype at end of output?
Advertisement
Answer
Use the .values
attribute.
Example:
JavaScript
1
10
10
1
In [158]: s = pd.Series(['race','gender'], index=[1,2])
2
3
In [159]: print(s)
4
1 race
5
2 gender
6
dtype: object
7
8
In [160]: s.values
9
Out[160]: array(['race', 'gender'], dtype=object)
10
You can convert to a list or access each value:
JavaScript
1
3
1
In [161]: list(s)
2
Out[161]: ['race', 'gender']
3