当我在dataframe中的列上运行函数时,我一直得到AttributeError: 'DataFrame' object has no attribute 'column'。
def reform (column, dataframe):
if dataframe.column.nunique() > 2 and dataframe.column.dtypes == object:
enc.fit(dataframe[['column']])
enc.categories_
one
我有一个分组的DataFrame,我希望得到这些组,这样以后我可以迭代它们,但是.groups正在返回AttributeError: 'DataFrame' object has no attribute 'groups'
test = temp.groupby(['global company key','calendar year'])[['columnA','columnB', 'columnC']].sum()
数据示例:
这是什么意思?AttributeError:“worksheet”对象没有属性“worksheet”--当我运行代码时出现了这个错误,并且我不知道它意味着什么。
整个错误是:
2 Jan = Jan.worksheet('01')
----> 3 while Jan.worksheet() != 31:
4 Jan = get_as_dataframe(Jan)
5 Jan = pd.DataFrame(Jan)
AttributeError:“工作表”对象没有属性“工作表”
--这是指向同一代码中的另一个问题的链接。
Ja
我试图为DataFrame的子类编写一个包装器方法
class SubDataFrame(DataFrame):
...
a = SubDataFrame()
b = a.loc[row, column]
在最后一行中,我希望在超类处理SubDataFrame之前或之后分别处理类loc中的元数据。
我不知道如何实现这个表示法,因为如果我只是定义
def loc(self, *args, **kwargs)
方法,在SubDataFrame中,loc[]括号表示法不起作用。(AttributeError: instancemethod has no attribute getitem)。
我正在尝试将Apache中的熊猫DataFrame转换为PCollection。不幸的是,当我使用to_pcollection()函数时,我得到以下错误: AttributeError: 'DataFrame' object has no attribute '_expr' 有谁知道怎么解决这个问题吗?我使用的是pandas=1.1.4、beam=2.25.0和Python3.6.9。
我试图在Google Colab中的一个打开的Google工作表中写入一个数据帧,但我得到了错误:
AttributeError:“Worksheet”对象没有属性“”update“”
我记录并测试了直到出现错误的部分。
# General Imports
# Example at https://colab.research.google.com/notebooks/io.ipynb
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
f
我用金融工具来获取期权链信息。在yfinance文档中,它说当检索到的数据将是熊猫的数据。
import pandas as pd
import numpy as np
import yfinance as yf
#retrieving for specific date
data = tk.option_chain('2021-03-26')
输出如下:
然后我试着用这个来分割文本
data['ExpirationDate'] = data['contractSumbol'].str.slice(start=4, sto
当我用功能工具定义实体集时,我得到了以下错误消息:
AttributeError:'str‘对象没有属性'copy’
这是我的密码:
import featuretools.variable_types as vtype
es = ft.EntitySet(id="Policy")
es = es.entity_from_dataframe(entity_id="Policy", dataframe='policy_df',index='Policy_no',variable_types={'P
使用PCA和绘制的散射点将DataFrame中的数值列从5列减少到2列之后,我进行了DataFrame聚类。
pc=PCA(n_components = 2).fit_transform(scaled_df)
scaled_df_PCA= pd.DataFrame(pc, columns=['pca_col1','pca_col2'])
#Then I did the KMeans and its plotting
label_PCA=final_km.fit_predict(scaled_df_PCA)
scaled_df_PCA["label_
我正在尝试创建恶意软件分类器,但遇到错误
AttributeError: 'Series' object has no attribute 'Id. Not sure of the error.
Traceback (most recent call last):
File"C:/Users/Afiqmatters/PycharmProjects/MajorProject/feature_extraction.py", line 23, in <module>
rids = [mids.loc[i].Id for i in rchoice
我当时在IBM的数据平台上工作。我能够将数据加载到pyspark数据框架中,并创建了一个星星之火SQL表。分割数据集后,将其输入到分类算法中。它会产生诸如spark数据无法加载的错误。所需的雷达。
from sklearn.ensemble import RandomForestRegressor`
from sklearn.model_selection import train_test_split`
from sklearn import preprocessing`
import numpy as np`
X_train,y_train,X_test,y_test = train_t
我有包含以下格式的df列:2020-04-20T03:18:07.000+0000,我想将它转换成如下格式:2020-04-20 03:18:07.000000
我就是这样做的:
def _to_timestamp(cls, col):
"""
Convert a column of a dataframe from String to Timestamp if applicable
:param col: A Series object representing a column of a datafram
我正在使用AttributeError: 'property' object has no attribute 'append'运行匹配项目的循环,并尝试使用fuzzywuzzy将结果保存到数据帧中,但我得到了错误fuzzywuzzy 在过去的几天里,我一直被困在这个问题上。理想情况下,我希望将5行匹配项添加到数据帧的底部--列应该包括fuzzywuzzy匹配项和相应的分数。下面的代码片段... x = 0
matchDF = pd.DataFrame.empty
for index, value in theData.head(5).iteritems():
我正在尝试使用Tweepy从Twitter的API中提取信息。90%的代码运行良好,但是当我尝试从每条推文中获取followers_count时,我会遇到一个错误。
我使用的代码是:
# Running only on handle returns a dataframe
tweets = api.user_timeline(user_id=user_id, count=number_tweets, tweet_mode="extended")
print("Number of tweets extracted: {}.\n".format(len(tweet
使用Tweepy库,我连接了一个Twitter帐户的凭证,并将与感兴趣的术语相关的实时tweet进行流,然后将它们保存到一个.txt文件中。
然后我想把我们收集到的所有数据都读入熊猫DataFrame
我该怎么做,拜托。
这是我的密码:
cursor = tweepy.Cursor(api.user_timeline, id='CarrefourFrance',tweet_mode='extended').items(33)
with open('t.txt', 'w') as f:
for tweet in curso
我在Python中使用Tweepy流式传输Tweet。代码将显示以下错误并退出:
AttributeError: 'NoneType' object has no attribute 'bounding_box'
tweets_df = pd.DataFrame()
for tweet in tqdm(tweets_copy):
hashtags = []
try:
for hashtag in tweet.entities["hashtags"]:
hashtags.append(hash