[Maybe Python] It's just the 100th article, so I'll pull out the article data, make a simple ranking, and comment [Pandas]

Hello everybody

Well, it's a good time for New Year's Eve, but recently I haven't watched TV for a long time, and when I was wondering if there was any entertainment, Qiita's article was 99, so I made it with an appropriate ranking, this As soon as I thought about looking back. I did a little bit of data formatting because it was easy to use pandas.

I think it was so useful, but I would appreciate it if you could read it if you are free.

Get the data

This time, I will use Python and Pandas to get the data and format it, so I will use google colaboratory for quick use. This is a Jupyter that can be used on the Web, so if you want to process data easily, it is convenient to use this.

Get list

First of all, I will pull out my article data using API. Here, API to get a list of my articles is used.

import requests
import json
import pandas as pd

url = 'https://qiita.com//api/v2/authenticated_user/items?per_page=100'
header = {
    'Content-Type': 'application/json',
    'Charset': 'utf-8',
    'Authorization': f'Bearer {token}'
}
res = requests.get(url=url, headers=header)

Get the token at https://qiita.com/settings/applications.

When I do this, I'm stuck with data json inside res. See the API Specifications (https://qiita.com/api/v2/docs#%E6%8A%95%E7%A8%BF) for a detailed response.

Get detailed data

By the way, even if you bring your own article list with this API, for some reason page_views_count is returned with None, so you need to bring your own articles individually to get this. So, use Individual acquisition API to acquire each data.

data = res.json()
item_list = []
url = 'https://qiita.com//api/v2/items/'
header = {
    'Content-Type': 'application/json',
    'Charset': 'utf-8',
    'Authorization': f'Bearer {token}'
}
for item in data:
  target = url + item['id']
  res = requests.get(url=target, headers=header)
  item_list.append(res.json())

Now, after a little annoying act of fetching 99 pieces of data individually, we have all the necessary data.

Format the data

Now that we have the data, we will format the data with pandas.

df = pd.json_normalize(item_list)
df['view_like_rate'] = df['likes_count']/df['page_views_count']
pd.set_option('display.max_columns', 100)
pd.set_option('display.width', 1000)

df.plot.scatter(x='page_views_count', y='likes_count')

Now you can get the graph below. qiita_graph.png From this graph, it goes without saying that there is a strong correlation between page_view_count (views) and likes_count (LGTMs), and the correlation coefficient is as high as 0.855825.

Ranking

Well, so far it's just a bonus, and for me it's the main subject, but for some people it's a bonus.

LGTM number

Ranking the number of LTGMs that contribute to contribution. You can think of it as the ranking of the articles that have received the most evaluation.

subdf = df.sort_values('likes_count', ascending=False)
print(subdf[['id', 'title', 'likes_count']])
Ranking title LGTM number
1 It's impossible not to use Composer for PHP development! Basics 689
2 Persuasive material explaining the advantages of containers for introducing Docker 660
3 How to get started with container development 547
4 Tutorial for writing test code in Laravel 326
5 What's new in ES6:I checked the "let" and "const" declarations 299

that? Before I knew it, "It's impossible not to use Composer in PHP development! Basics" is ranked first. It's reversed.

For the time being, look back one by one.

It's impossible not to use Composer for PHP development! Basics

I was so angry that I couldn't stand the legacy system that didn't use composer. I used to mess around with zip-decompressing the entire code into git, so it's a good idea to do it this way! I'm trying to write it and push it against the company, this. For a while, I also appeared in google snippets.

By the way, the sequel to this isn't popular at all.

Persuasive material explaining the advantages of containers for introducing Docker

I was enthusiastic about containers at the time, and I wrote this to recommend container development and container operation to colleagues in another project. There wasn't much reaction on the first day, but I remember explosively buzzing for some reason.

It's a material to persuade, so I'm writing it really seriously. There was a person who wrote "It's not so simple" in Hatena, but well, it's the one who wrote it with the feeling that it should be understood.

How to start container development

It's also about containers and slides. At the time of writing this, there were quite a few vagrant + virtual boxes, so I made a document so that I could do it in a container and announce it at a study session, so I thought that I could earn good if I got on Qiita. I think I wrote it with such an idea.

Tutorial for writing test code in Laravel

It was easy to test Laravel's request-response, so I wrote it as an article. At that time, the company didn't have a culture of writing tests at all, so I was wondering, and since my case was perl and I was testing request-response, I wondered if there was something similar. I was impressed with Laravel. It was an aggressive time to rewrite all existing apps with Laravel.

What's new in ES6: I checked the "let" and "const" declarations

I'm not sure why this was ranked in. At that time, I was studying javascript, and I was studying how to write with new specifications, but I encountered a situation where there were multiple variable declarations, and in the first place I was not so particular about variable declarations in PHP. It's an article I wrote after studying, feeling fresh. It still comes with a little LGTM.

Number of views

Next, let's look at the number of views. The number of views increases mainly due to the influx of searches. In other words, the content of the article was so easy to get caught in the search word.

Ranking title Number of views
1 It's impossible not to use Composer for PHP development! Basics 158954
2 What's new in ES6:I checked the "let" and "const" declarations 96796
3 Persuasive material explaining the advantages of containers for introducing Docker 73117
4 ES2015 new features:JavaScript class and method 58419
5 Solving time series predictions using one-dimensional convolution with Keras 55659

composer is overwhelming. There were so many. .. .. There are quite a few articles I wrote when I started studying JavaScript, and I wondered if everyone would search in the same way.

So let's comment on the article that came out for the first time.

ES2015 New Feature: JavaScript Class and Method

It is doubtful that you can earn a lot of search influx in JavaScript-related stories. This is also the one I wrote at the same time as "New feature of ES6: I checked the" let "and" const "declarations" that I saw in the LGTM number. At that time, class was finally applied with JavaScript! I remember it was a mysterious tension like this. I wonder if it can be written in the same way as PHP. .. .. It was like that.

This article rephrases ES6 to ES2015.

Solving time series predictions using one-dimensional convolution with Keras

When I was thinking of learning the waveform of sound somehow and making a music generator, I thought that it would be possible to understand music with the idea that it can be calculated at a high speed and grasp the waveform with a pattern. This is the one I wrote as a verification. It's an article written by an amateur about machine learning, so I'm sorry for those who have been searched.

LGTM/Views

If you read it but didn't LGTM, it may mean that the article wasn't very valuable. So, let's browse and see the articles that LGTM was more likely to come to.

subdf = df.sort_values('view_like_rate', ascending=False)
print(subdf[['title', 'view_like_rate', 'likes_count', 'page_views_count']])
Ranking title LGTM rate LGTM number Number of views
1 PHP7.I wondered if Laravel would be faster if I added 4 preloads and verified 0.017831 171 9590
2 Echo or print for debugging_Write a test instead of writing r 0.014663 86 5865
3 How to get started with container development 0.012155 547 45003
4 [Verification]Write code based on code I want to write code~Make an implementation from interface 0.011628 3 258
5 ES2015 new features:I want to master the generator 0.011559 35 3028

Surprisingly, there are many new faces. Basically, the number of views is small, so it seems that LGTM has become easier to attach as a result of narrowing down the target. The number of views and the number of LGTMs are large just for the beginning of container development, but I wonder if you were satisfied with the results you saw in the search.

I will comment a little on the article that appeared for the first time.

I wondered if Laravel would be faster if I added PHP7.4 preload

I just wanted to use PHP 7.4. With the preload, the files specified in advance will be in the read state, so I think it's probably faster because I don't have to look at the files or look at the cache with the time stamp or judge why I didn't look at it. This is the one I did. If you are using a container, you can only use it at startup.

Write a test instead of writing echo or print_r for debugging

It is a product of an era when I was told to write a test sourly in the company at that time, and I was urged to write more tests using the article I wrote as a weapon. I do echo, print_r, var_dump, but it doesn't leave a record, so let's keep a record. To put it the other way around, debugging is more or less everyone writing tests. Just not left.

[Verification] I want to write code based on code ~ Create an implementation from interface

This is a recent article. Anyway, there is a lot of material when writing code, and I hate spending time creating files when creating new functions rather than troublesome logic, so I made this article because I wanted to write a generator. There are various architectures in the world, but if the amount of files increases, it is better to make a generator. It's really hard when it comes to simple work.

ES2015 new feature: I want to master the generator

It was around the time when generators were just coming to JavaScript. I think PHP had a generator around this time, but I wrote this article because I wanted to understand who it was. ES6 has become ES2015, so it's following the soberness.

Summary

So, it was the 100th article and the last article of this year, so I tried to give it a commemorative atmosphere. I don't know if this will be useful, but it might be a good idea to look back at your own article.

This time it is like this.

Recommended Posts

[Maybe Python] It's just the 100th article, so I'll pull out the article data, make a simple ranking, and comment [Pandas]
I tried to find out the difference between A + = B and A = A + B in Python, so make a note
Let's make a simple game with Python 3 and iPhone
Build a Python environment and transfer data to the server