#実現したいこと
このコードを完成させて分析ツールを作りたい
発生している問題・エラーメッセージ
AttributeError Traceback (most recent call last)
<ipython-input-110-1e7d6bfbf47b> in <module>
9 manhattan_dummy=input_sheet_df.Manhattan_dummy
10 #プライベートルームか
---> 11 private_dummy=input_sheet_df.private_dummy
12 #家一軒貸し出しか
13 home_dummy=input_sheet_df.home_dummy
~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in getattr(self, name)
5177 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5178 return self[name]
-> 5179 return object.getattribute(self, name)
5180
5181 def setattr(self, name, value):
AttributeError: 'DataFrame' object has no attribute 'private_dummy'
#該当のソースコード
import matplotlib.pyplot as plt
import scipy.stats
manhattan_dummy=input_sheet_df.Manhattan_dummy
private_dummy=input_sheet_df.private_dummy
home_dummy=input_sheet_df.home_dummy
shared_dummy=input_sheet_df.shared_dummy
price=input_sheet_df.price
minimum_nights=input_sheet_df.minimum_nights
number_of_reviews=input_sheet_df.number_of_reviews
reviews_per_month=input_sheet_df.reviews_per_month
calculated_host_listings_count=input_sheet_df.calculated_host_listings_count
availability_365=input_sheet_df.availability_365
result = scipy.stats.linregress(number_of_reviews,price)
print('傾き=', result.slope.round(4),'切片=', result.intercept.round(4), '信頼係数=', result.rvalue.round(4),
'p値=', result.pvalue.round(4), '標準偏差=', result.stderr.round(4))
result_slope = result.slope
result_intercept = result.intercept
plt.plot(number_of_reviews, [result_slope*u + result_intercept for u in number_of_reviews])
plt.scatter(number_of_reviews,price)
plt.title('price and number_of_reviews in Airbnb Dataset')
plt.ylabel('price')
plt.xlabel('number of reviews')
plt.show()
import statsmodels.api as sm
model = sm.OLS(price, sm.add_constant(number_of_reviews))
result = model.fit()
print(result.summary())
print('p-values\n', results.pvalues)
#自分で調べたことや試したこと
類例を検索しましたが、解決方法を見つけられず、読み込むEXCELファイルの再UL等も試行しましたが、エラーの解決になりませんでした。。
初心者ですので、サポートしてくださる方に感謝します。
#追記)読み込ませるエクセルファイルデータのサンプル(7行分のみ転記)*少し見づらくてすみません
id name host_id host_name neighbourhood_group Manhattan_dummy neighbourhood latitude longitude room_type price minimum_nights number_of_reviews last_review reviews_per_month calculated_host_listings_count availability_365
0 2539 Clean & quiet apt home by the park 2787 John Brooklyn 0 Kensington 40.64749 -73.97237 Private room 149 1 9 2018-10-19 0.21 6 365
1 2595 Skylit Midtown Castle 2845 Jennifer Manhattan 1 Midtown 40.75362 -73.98377 Entire home/apt 225 1 45 2019-05-21 0.38 2 355
2 3647 THE VILLAGE OF HARLEM....NEW YORK ! 4632 Elisabeth Manhattan 1 Harlem 40.80902 -73.94190 Private room 150 3 0 NaT NaN 1 365
3 3831 Cozy Entire Floor of Brownstone 4869 LisaRoxanne Brooklyn 0 Clinton Hill 40.68514 -73.95976 Entire home/apt 89 1 270 2019-07-05 4.64 1 194
4 5022 Entire Apt: Spacious Studio/Loft by central park 7192 Laura Manhattan 1 East Harlem 40.79851 -73.94399 Entire home/apt 80 10 9 2018-11-19 0.10 1 0
5 5099 Large Cozy 1 BR Apartment In Midtown East 7322 Chris Manhattan 1 Murray Hill 40.74767 -73.97500 Entire home/apt 200 3 74 2019-06-22 0.59 1 129
6 5121 BlissArtsSpace! 7356 Garon Brooklyn 0 Bedford-Stuyvesant 40.68688 -73.95596 Private room 60 45 49 2017-10-05 0.40 1 0
7 5178 Large Furnished Room Near B'way 8967 Shunichi Manhattan 1 Hell's Kitchen 40.76489 -73.98493 Private room 79
回答1件
あなたの回答
tips
プレビュー