0
import pandas as pd
import numpy as np
df = pd.DataFrame({'Number':[np.linspace(0,10,11,dtype=int)],'Year':[np.linspace(2000,2010,11,dtype=int)],'Person':[np.linspace(10,20,11,dtype=int)],'Age':[np.linspace(30,40,11,dtype=int)]})
df
4

1 回答 1

2

删除[ ]您的价值观:

import pandas as pd
import numpy as np

df = pd.DataFrame(
    {
        "Number": np.linspace(0, 10, 11, dtype=int),
        "Year": np.linspace(2000, 2010, 11, dtype=int),
        "Person": np.linspace(10, 20, 11, dtype=int),
        "Age": np.linspace(30, 40, 11, dtype=int),
    }
)
print(df)

印刷:

    Number  Year  Person  Age
0        0  2000      10   30
1        1  2001      11   31
2        2  2002      12   32
3        3  2003      13   33
4        4  2004      14   34
5        5  2005      15   35
6        6  2006      16   36
7        7  2007      17   37
8        8  2008      18   38
9        9  2009      19   39
10      10  2010      20   40

编辑:如评论中所述,您可以使用range()ornp.arange以及...

于 2021-05-10T18:35:56.130 回答