在python中生成数据帧的最简单方法是不使用pandas包吗?

在python中生成数据帧的最简单方法是不使用pandas包吗?,python,pandas,Python,Pandas,因此,我正在部署一个不能使用pandas的web应用程序。我在aws上使用python3和elastic beanstalk,目前还没有各种依赖项 我只需要在一个函数中使用熊猫——用法非常简单:制作一些数据帧,然后通过df.loc-->搜索它们有谁知道熊猫有什么好的替代品,它有df.loc[index,col]功能吗?你最好的选择是在dict中使用列表: df_eq = {'col1' : [list, of, column, data], 'col2' : [list, of

因此,我正在部署一个不能使用pandas的web应用程序。我在aws上使用python3和elastic beanstalk,目前还没有各种依赖项


我只需要在一个函数中使用熊猫——用法非常简单:制作一些数据帧,然后通过
df.loc
-->搜索它们有谁知道熊猫有什么好的替代品,它有
df.loc[index,col]
功能吗?

你最好的选择是在dict中使用列表:

df_eq = {'col1' : [list, of, column, data],
         'col2' : [list, of, column, data],
         ...,
         'coln-1' : [list, of, column, data],
         'coln' : [list, of, column, data]}
然后您可以使用类似于
loc

df_eq['coln'][idx]

您最好的选择是在dict中使用列表:

df_eq = {'col1' : [list, of, column, data],
         'col2' : [list, of, column, data],
         ...,
         'coln-1' : [list, of, column, data],
         'coln' : [list, of, column, data]}
然后您可以使用类似于
loc

df_eq['coln'][idx]

我只会使用
numpy
。此外,索引
numpy
比索引w/
pandas

Ar_data = np.array([["gyrados","raichu","mu","dragonair","vaporeon"],["water","electric","normal","dragon","water"], [0,0,0,1,2]]).T
Ar_data
# array([['gyrados', 'water', '0'],
#        ['raichu', 'electric', '0'],
#        ['mu', 'normal', '0'],
#        ['dragonair', 'dragon', '1'],
#        ['vaporeon', 'water', '2']], 
#       dtype='<U9')

# Index w/ ints `.iloc`
Ar_data[3,1]
# 'dragon'

fields = ["pokemon","status","meta"]
observations = ["p1","p2","p3","p4","p5"]

# Index w/ labels `.loc`
Ar_data[3,fields.index("pokemon")]
# 'dragonair'

Ar_data[observations.index("p4"),fields.index("pokemon")]
# 'dragonair'

# Time it
DF_data = pd.DataFrame(Ar_data, columns=fields, index=observations)
%timeit DF_data.iloc[3,1]
%timeit Ar_data[3,1]
# 10000 loops, best of 3: 129 µs per loop
# The slowest run took 21.69 times longer than the fastest. This could mean that an intermediate result is being cached.
# 1000000 loops, best of 3: 384 ns per loop
Ar_data=np.数组([[“gyrados”、“raichu”、“mu”、“dragonair”、“vaporeon”]、[“water”、“electric”、“normal”、“dragon”、“water”]、[0,0,0,1,2]])
Ar_数据
#数组([['gyrados','water','0'],
#['raichu','electric','0'],
#['mu','normal','0'],
#['dragonair','dragon','1'],
#[‘蒸汽’、‘水’、‘2’],

#dtype='我只会使用
numpy
。而且,索引
numpy
比索引w/
pandas

Ar_data = np.array([["gyrados","raichu","mu","dragonair","vaporeon"],["water","electric","normal","dragon","water"], [0,0,0,1,2]]).T
Ar_data
# array([['gyrados', 'water', '0'],
#        ['raichu', 'electric', '0'],
#        ['mu', 'normal', '0'],
#        ['dragonair', 'dragon', '1'],
#        ['vaporeon', 'water', '2']], 
#       dtype='<U9')

# Index w/ ints `.iloc`
Ar_data[3,1]
# 'dragon'

fields = ["pokemon","status","meta"]
observations = ["p1","p2","p3","p4","p5"]

# Index w/ labels `.loc`
Ar_data[3,fields.index("pokemon")]
# 'dragonair'

Ar_data[observations.index("p4"),fields.index("pokemon")]
# 'dragonair'

# Time it
DF_data = pd.DataFrame(Ar_data, columns=fields, index=observations)
%timeit DF_data.iloc[3,1]
%timeit Ar_data[3,1]
# 10000 loops, best of 3: 129 µs per loop
# The slowest run took 21.69 times longer than the fastest. This could mean that an intermediate result is being cached.
# 1000000 loops, best of 3: 384 ns per loop
Ar_data=np.数组([[“gyrados”、“raichu”、“mu”、“dragonair”、“vaporeon”]、[“water”、“electric”、“normal”、“dragon”、“water”]、[0,0,0,1,2]])
Ar_数据
#数组([['gyrados','water','0'],
#['raichu','electric','0'],
#['mu','normal','0'],
#['dragonair','dragon','1'],
#[‘蒸汽’、‘水’、‘2’],

#dtype='如果您没有pandas,请获取pandas。使用内置dict对象捕获750 Mb文件可能会占用超过20 gb的ram,而pandas将使用类似4的内存读取该文件。您可以使用numpy吗?否则,如果您没有pandas,请获取pandas。使用内置dict对象捕获750 Mb文件可能会占用超过2 gb的内存0 gb内存,而pandas将使用like 4读取。您可以使用numpy吗?否则,下一个最好的方法可能是