teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コード

2020/07/10 13:13

投稿

pon244
pon244

スコア59

title CHANGED
File without changes
body CHANGED
@@ -2,12 +2,11 @@
2
2
  Python Jupyternotebook, macbook pro
3
3
 
4
4
  【実行結果】
5
- ![イメージ説明](4ffa27550298632d847bc2b4433f17e6.png)
5
+ ![イメージ説明](8f93c9f106478889a45f639940450ddd.png)
6
6
 
7
- 【したこと、試したこと
7
+ い結果
8
- コラムHuawei_EuropeSamsungMobileにそぞれ数字行きたい
8
+ 現状ままだと毎日更新すると毎日の推移が見ない。全部同じ数字します
9
- Dateの9月1仮設定しいますがイメージとしては毎そこ毎日の数字を入れてたいです。
9
+ 更新したの一番上、9/1に残って、更新したら9/2にいくようにしたいです。
10
- For分で入れてみましたが、うまく行かないので、基礎的な質問ですが、ご教授いただきたいです。
11
10
 
12
11
  【コード】
13
12
  ```ここに言語を入力
@@ -23,22 +22,29 @@
23
22
 
24
23
  #データフレームを作成すr。
25
24
 
25
+ #データフレームを作成すr。
26
+
26
27
  df_TW_Followers = pd.DataFrame()
27
28
  df_TW_Followers = pd.DataFrame(columns=["SamsungMobile","Huawei_Europe"],index=['09/01','09/02','09/03'])
28
29
  TwitterHandle=["SamsungMobile","Huawei_Europe"]
29
- df_TW_Followers
30
+ df_TW_Followers.index
30
31
  SamsungMobile = api.get_user(screen_name="SamsungMobile")
32
+ Huawei_Europe = api.get_user(screen_name="Huawei_Europe")
31
33
  SamsungMobile.followers_count
34
+ Huawei_Europe.followers_count
32
35
  #forで格納する
33
36
 
37
+ #forで格納する
38
+
34
39
  for i in TwitterHandle:
35
40
  url_financials= api.get_user(screen_name=str(i))
36
41
  print(i + " done!")
37
- df_TW_Followers.at[str(i),"SamsungMobile"] =url_financials.followers_count
42
+ df_TW_Followers.at[df_TW_Followers.index,"SamsungMobile"] =SamsungMobile.followers_count
43
+ df_TW_Followers.at[df_TW_Followers.index,"Huawei_Europe"] =Huawei_Europe.followers_count
38
44
 
39
-
40
45
 
41
46
  print("ALL done!")
47
+
42
48
  ```
43
49
 
44
50
  【欲しい結果】

1

修正

2020/07/10 13:13

投稿

pon244
pon244

スコア59

title CHANGED
File without changes
body CHANGED
@@ -39,4 +39,12 @@
39
39
 
40
40
 
41
41
  print("ALL done!")
42
- ```
42
+ ```
43
+
44
+ 【欲しい結果】
45
+ 下記のように入れたいですが、現状は新たに行にHuawei_Europeが入ってしまいます
46
+ |列1|Huawei_Europe|SamsungMobile|
47
+ |:--|:--:|--:|
48
+ |9/1|100|200|
49
+ |9/2|200|222|
50
+ |9/3|300|230|