alcohol = pd.read_csv('https://andybek.com/pandas-drinks', usecols=['country','wine_servings'], index_col='country', squeeze=True)
当使用关键字squeeze将一列的字符串转换为序列时,我得到一个错误TypeError: read_csv() got an unexpected keyword argument 'squeeze'。
squeeze
TypeError: read_csv() got an unexpected keyword argument 'squeeze'
f45qwnt81#
read_csv不再有squeeze参数。它在Pandas 2.0中被删除。
read_csv
read_csv()
在阅读CSV后使用DataFrame.squeeze('columns')。
DataFrame.squeeze('columns')
zy1mlcev2#
read_csv()函数中的squeeze参数在pandas库中不可用。squeeze参数用于其他pandas函数,如DataFrame.squeeze()或Series.squeeze(),以将具有单列或单轴的DataFrame或Series转换为Series。
DataFrame.squeeze()
Series.squeeze()
import pandas as pd alcohol = pd.read_csv('https://andybek.com/pandas-drinks', usecols=['country', 'wine_servings'], index_col='country') alcohol = alcohol['wine_servings'].squeeze()
2条答案
按热度按时间f45qwnt81#
read_csv
不再有squeeze
参数。它在Pandas 2.0中被删除。squeeze
,...从read_csv()
(...,GH43427)在阅读CSV后使用
DataFrame.squeeze('columns')
。zy1mlcev2#
read_csv()
函数中的squeeze
参数在pandas库中不可用。squeeze参数用于其他pandas函数,如DataFrame.squeeze()
或Series.squeeze()
,以将具有单列或单轴的DataFrame或Series转换为Series。