ndex_df = pd.read_excel('../data/index.xlsx', names=["WindNumber", "fan_diam", "rated_power",\ "speed_in", "speed_out", "speed_min", "speed_max"]) index_df
时间: 2023-07-21 18:57:17 浏览: 55
这段代码是使用pandas库中的read_excel函数读取Excel文件,并将文件中的内容存储在名为index_df的DataFrame对象中。其中,文件路径为'../data/index.xlsx',列名为["WindNumber", "fan_diam", "rated_power", "speed_in", "speed_out", "speed_min", "speed_max"]。最后,将DataFrame对象输出到控制台。
相关问题
TypeError: NDFrame.to_excel() got an unexpected keyword argument 'ndex'
这个错误是因为 `to_excel()` 方法没有 `ndex` 这个参数。正确的参数是 `index`。所以你需要把 `ndex` 改为 `index`。比如:
```python
import pandas as pd
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
df.to_excel("output.xlsx", index=False)
```
这个例子中,我们将一个 DataFrame 写入到 Excel 文件中,并且指定不写入行索引。
用pandas编程,df2=pd.DataFrame(np.arange(12).reshape(3,4 ), ndex=[a,'b,c',columns=[A,B,C,"D)) df3=pd.DataFrame(np.arange(13,25).reshape( 3,4), index=[a',c, d',columns=[A,'E,C,F')对df2,df3横向堆叠(inner outer各做堆叠)
可以使用pandas的concat函数来实现横向堆叠,inner和outer分别对应参数join的取值为inner和outer。具体代码如下:
# inner横向堆叠
df_inner = pd.concat([df2, df3], axis=1, join='inner')
print(df_inner)
# outer横向堆叠
df_outer = pd.concat([df2, df3], axis=1, join='outer')
print(df_outer)
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)