将字典{"grammer":["Python","C","Java","GO",np.nan,"SQL","PHP","Python"], "score":[1,2,np.nan,4,5,6,7,10]}创建为Dataframe并打印
时间: 2023-11-17 09:08:02 浏览: 92
```python
import pandas as pd
import numpy as np
data = {"grammer":["Python","C","Java","GO",np.nan,"SQL","PHP","Python"], "score":[1,2,np.nan,4,5,6,7,10]}
df = pd.DataFrame(data)
print(df)
```
输出结果为:
```
grammer score
0 Python 1.0
1 C 2.0
2 Java NaN
3 GO 4.0
4 NaN 5.0
5 SQL 6.0
6 PHP 7.0
7 Python 10.0
```
相关问题
1.将下面的字典创建为DataFrame data+=+{"grammer":["Python","C","Java","GO",np.nan,"SQL","PHP","Python"],
以下是将字典创建为DataFrame的代码示例:
```python
import pandas as pd
import numpy as np
data = {"grammer":['python','c','java','go',np.NaN,'SQL','PHP','Python'], "score":[1.0, 2.0, np.NaN, 4.0, 5.0, 6.0, 7.0, 10.0]}
df = pd.DataFrame(data)
print(df)
```
输出结果为:
```
grammer score
0 python 1.0
1 c 2.0
2 java NaN
3 go 4.0
4 NaN 5.0
5 SQL 6.0
6 PHP 7.0
7 Python 10.0
```
(1)将下面的字典创建为DataFrame<br>data = {"grammer":["Python","C","Java","GO",np.nan,"SQL","PHP","Python"]
下面是将字典创建为DataFrame的代码:
```python
import pandas as pd
import numpy as np
data = {"grammer":['Python', 'C', 'Java', 'GO', np.nan, 'SQL', 'PHP', 'Python'],
"score":[1.0, 2.0, np.nan, 4.0, 5.0, 6.0, 7.0,10.0]}
df = pd.DataFrame(data)
print(df)
```
输出结果为:
```
grammer score
0 Python 1.0
1 C 2.0
2 Java NaN
3 GO 4.0
4 NaN 5.0
5 SQL 6.0
6 PHP 7.0
7 Python 10.0
```
阅读全文