赞
踩
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
In [
3
]:
import
pandas as pd
In [
4
]: a
=
pd.Series([
1
,
2
,
3
])
In [
5
]: b
=
pd.Series([
2
,
3
,
4
])
In [
6
]: c
=
pd.DataFrame([a,b])
In [
7
]: c
Out[
7
]:
0
1
2
0
1
2
3
1
2
3
4
|
不过pandas直接用列表生成dataframe只能按行生成,如果是字典可以按列生成,比如:
1
2
3
4
5
6
7
8
|
In [
8
]: c
=
pd.DataFrame({
'a'
:a,
'b'
:b})
In [
9
]: c
Out[
9
]:
a b
0
1
2
1
2
3
2
3
4
|
DataFrame(
list
(
zip
(a, b)))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。