我想在Python中创建一个新对象,该对象对应于数据框中女性成员的名字和姓氏。
import numpy as np
import pandas as pd
Index = np.array(['B1','L1','T1','G1','L2'])
Name = pd.Series(['Bob','Linda','Tina','Gene','Louise'] , index = Index )
Gender = pd.Series(['Male','Female','Female','Male','Female'] , index = Index )
Age = pd.Series([46,42,13,11,9] , index = Index )
Occupation = pd.Series(['Chef','Restaurateur','Student','Student','Student'] , index = Index )
Rating = pd.Series([7,6,9,9,8] , index = Index )
burger = pd.DataFrame(data=dict(Name=Name,Gender=Gender,Age=Age,Occupation=Occupation,Rating=Rating))
burger
我知道下面的代码是如何从一个系列中选择某些内容,但我不确定在涉及数据帧时如何选择
burger.loc[]
burger.iloc[]
试试这个,输出是一个数据帧
如果您需要一个系列作为输出
相关问题 更多 >
编程相关推荐