当前位置:网站首页>Your wechat nickname may be betraying you
Your wechat nickname may be betraying you
2022-07-06 15:20:00 【Jane said Python】
Contents of this article :
- One 、 Preface
- Two 、Let’s get it
- 3、 ... and 、 Have some fun , Data cleaning 、 analysis
- Four 、 Emotional analysis through nicknames ( The text comes from Zhihu netizens )
- 5、 ... and 、 appendix : Reference documents
One 、 Preface
Hello everyone , The first thing to say is , This is a technical article , It's also an article not
Technical papers , What we share today is , When I get the wechat applet The English name is
Of 3500 Multiple wechat user nicknames 、 After age , The results are as follows ...
Two 、Let’s get it
1. Access to basic information
1. visit The English name is
The basic user information interface , obtain The English name is
User's wechat name (NickName
)、 Number of visits (Count
)、 Aggregate data set (ResponseData
), And put the wechat name in the file .
# Get all the number of users and related information
def get_json():
# Gain entry
search_url = ' English name user interface , Welcome to scan the code and use the English name , Create an English name that best suits you '
# send out http request , Get request page
search_response = requests.get(search_url)
# Set encoding
search_response.encoding = 'UTF-8'
# Turn the page into json Code format
search_json = search_response.json()
# Get the data we need , It's a list format
our_data = search_json['ResponseData']
list_len = len(our_data)
print(' The total number of users is :' + str(list_len))
user_visit_numbers = 0
data_research = 0
NickName = []
for x in our_data:
user_visit_numbers= x['Count'] + user_visit_numbers
if x['NickName'] == '':
data_research += 1
NickName.append(x['NickName'])
print(" The number of wechat name acquisition failures :"+str(data_research))
print(NickName)
name = [' Wechat name ']
file_test = pd.DataFrame(columns=name, data=NickName)
file_test.to_csv(r'I:/data.csv', encoding='utf-8',index=False)
print(' Total visits :' + str(user_visit_numbers))
Running results :
The total number of users is :3549
The number of wechat name acquisition failures :0
Total visits :4573
2. Read all wechat names , data classification
(1) Read wechat name
# Read the file , Take out the wechat name
def get_name():
NickName = []
with open('I:/data.csv','r',encoding='utf8') as file :
i = 0
for line in file:
if i == 0: # Remove the meter head
i = 1
continue
line = line.strip() # Remove line breaks
NickName.append(line)
return NickName
(2) The data are divided into the following six categories
Chinese name | Variable name | data type |
---|---|---|
All Chinese nicknames | ch_name | list |
All English Nicknames | en_name | list |
Chinese and digital mixed nicknames | ch_di_name | list |
Include picture emoticon nicknames | img_name | list |
Other nicknames | other_name | list |
# ch :Chinese
ch_name_number = 0
ch_name = []
# en :English
en_name_number = 0
en_name = []
# di : digtal
di_name_number = 0
di_name = []
# img : image
img_name_number = 0
img_name = []
# ch_di : Chinese and digtal
ch_di_name = []
# other : other
oth_name_number = 0
oth_name = []
(3) Data classification judgment
# Nicknames are judged in Chinese
def is_all_ch(keyword):
for c in keyword:
# Contains common Chinese characters
if not ('\u4e00' <= c <= '\u9fa5'):
return False
return True
# Nicknames are judged in English
def is_all_en(keyword):
# It can't be all spaces or the first place is spaces
if all(ord(c) == 32 for c in keyword) or keyword[0] == ' ':
return False
# Allow spaces and English to coexist ( for example :Xist A)
if not all(65 < ord(c) < 128 or ord(c) == 32 for c in keyword):
return False
return True
# Nickname full number judgment
def is_all_di(keyword):
for uchar in keyword:
if not (uchar >= '\u0030' and uchar <= u'\u0039'):
return False
return True
# Nicknames contain emoticons to judge
def have_img(keyword):
# Here is one of most of the pictures unicode Encoding set
# View details :https://en.wikipedia.org/wiki/Emoji
img_re = re.compile(u'['
u'\U0001F300-\U0001F64F'
u'\U0001F680-\U0001F6FF'
u'\u2600-\u2B55]+',
re.UNICODE)
if img_re.findall(keyword) :
return True
return False
# chinese + Digital nickname judgment
def is_ch_di(keyword):
for c in keyword:
if not ('\u4e00' <= c <= '\u9fa5') and not (c >= '\u0030' and c <= u'\u0039'):
return False
return True
(4) Data classification and calculation of various quantities
list_name = get_name()
print(" All in all :"+str(len(list_name))+" Wechat name ")
for i in range(len(list_name)):
result = classification_name(list_name[i])
if result == 'ch': # chinese
ch_name_number +=1
ch_name.append(list_name[i])
if result == 'en': # english
en_name_number +=1
en_name.append(list_name[i])
if result == 'di': # Numbers
di_name_number +=1
di_name.append(list_name[i])
if result == 'img': # Facial expression
img_name_number +=1
img_name.append(list_name[i])
if result == 'ch_di': # Chinese and numbers
ch_di_name_number +=1
ch_di_name.append(list_name[i])
if result == 'other': # other
oth_name_number +=1
oth_name.append(list_name[i])
print(" Number of pure Chinese nicknames :"+ str(ch_name_number))
# print(ch_name)
print(" Number of pure English Nicknames :"+ str(en_name_number))
#print(en_name)
print(" Number of pure digital nicknames :"+ str(di_name_number))
# print(di_name)
print(" Including the number of emoticons :"+ str(img_name_number))
# print(img_name)
print(" Number of Chinese and digital mixed nicknames :"+ str(ch_di_name_number))
print(ch_di_name)
print(" Number of other nicknames :"+ str(oth_name_number))
# print(oth_name)
Running results :
All in all :3549 Wechat name
Number of pure Chinese nicknames :1514
Number of pure English Nicknames :569
Number of pure digital nicknames :9
Including the number of emoticons :400
Number of Chinese and digital mixed nicknames :19
Number of other nicknames :1038
3. Get user paintings ( Only get the age of the user )
3. visit The English name is
User portrait interface , Get close to 30 God Active users
and new user
The age of
# Get the age of the user
def get_data():
# obtain token, And deal with
t = get_token().strip('"')
# And then we'll deal with the token Values and other parameters as post Parameter value of the method , Call user portrait api
post_user_api = " https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token="
post_user_url = post_user_api + t
# Access to get profile data ( Data in the past month )
data = json.dumps({
"begin_date" : "2018-07-21",
"end_date" : "2018-08-19"})
# pick up information
user_portrait_data = get_info(post_user_url, data)
# Period of time
ref_date = user_portrait_data['ref_date']
# new user
visit_uv_new = user_portrait_data['visit_uv_new']
Active users
visit_uv = user_portrait_data['visit_uv']
# age group
print(ref_date )
print((visit_uv_new['ages']))
print((visit_uv['ages']))
Running results :
# id : Is the age group number name : Age group name value : Number of people in this age group
20180721-20180819
[{
'id': 0, 'name': ' Unknown ', 'value': 6}, {
'id': 1, 'name': '17 Under the age of ', 'value': 18}, {
'id': 2, 'name': '18-24 year ', 'value': 118}, {
'id': 3, 'name': '25-29 year ', 'value': 75}, {
'id': 4, 'name': '30-39 year ', 'value': 81}, {
'id': 5, 'name': '40-49 year ', 'value': 14}, {
'id': 6, 'name': '50 Years of age or older ', 'value': 7}]
[{
'id': 0, 'name': ' Unknown ', 'value': 6}, {
'id': 1, 'name': '17 Under the age of ', 'value': 20}, {
'id': 2, 'name': '18-24 year ', 'value': 147}, {
'id': 3, 'name': '25-29 year ', 'value': 88}, {
'id': 4, 'name': '30-39 year ', 'value': 95}, {
'id': 5, 'name': '40-49 year ', 'value': 20}, {
'id': 6, 'name': '50 Years of age or older ', 'value': 10}]
3、 ... and 、 Have some fun , Data cleaning 、 analysis
1. Visual analysis of wechat name type data
Core code :
# 1. Wechat name classification : Rose pie
from pyecharts import Pie
# Data obtained from the above code
attr = [" Pure Chinese nickname ", " Pure English nickname ", " Pure digital nicknames ", " Include emoticons nicknames ", " Chinese and digital mixed nicknames ", " Other nicknames "]
v1 = [1514, 569, 9, 400, 19, 1038]
pie = Pie(" Wechat name classification pie chart ", title_pos='center', width=900)
pie.add(
" Proportion ",
attr,
v1,
center=[50, 50],
is_random=True,
radius=[30, 75],
rosetype="area",
is_legend_show=False,
is_label_show=True,
)
pie.render("render_01.html")
Running effect :
It can be seen from it that , Wechat nicknames account for the most in Chinese , occupy
42.66%
, Second, other nicknames ( Mix Chinese and English 、 Characters and so on ), occupy29.25%
, The bigger class is the pure English nickname , occupy16.03%
, And include emoticon pack nicknames , occupy11.27%
, For example, pure digital nicknames and Chinese digital mixed nicknames are relatively less , The most common Chinese and digital mixed nicknames areOrganization name / full name + Contact information
, Some marketing numbers are often used , By contrast , Most people still like to use pure Chinese for nicknames , It embodies a kind of cultural feelings , I also introduced myself briefly , For example, my wechat name iscousin
, This is my nickname in junior high school , Friends say the old watch , It's not necessarily about relatives , Maybe I'm talking about , Ha ha ha .
2. Wechat user age visualization analysis
Core code :
# 2. User age : Rose pie
from pyecharts import Pie
# Data obtained from the above code
attr = [" Unknown ", "17 Under the age of ", "18-24 year ", "25-29 year ", "30-39 year ", "40-49 year ","50 Years of age or older "]
v1 = [12, 38, 265, 163, 176, 34,17]
pie = Pie(" Wechat user age pie chart ", title_pos='center', width=900)
pie.add(
" Proportion ",
attr,
v1,
center=[50, 50],
is_random=True,
radius=[30, 75],
rosetype="area",
is_legend_show=False,
is_label_show=True,
)
pie.render("render_02.html")
Running effect :
It can be seen from it that , In the age group ,
18-24 year
Of95-00 after
Most of them , achieve37.59%
, Next is30-39 year
Of80-90 after
, Proportion to24.97%
, Next to it is25-29 year
Of90-95 after
, Percentage23.12%
, Other age groups can be roughly divided into two categories : Partial children and partial old people , In all10.21%
, I personally think the reason for the small number of such people is : The child 、 The old people seldom play wechat , Not to mention wechat apps , The role of wechat for children is Play a game ( Login account ), For the old man , Wechat is mainly used for Chat , It's more complicated , The use of small programs may be more complicated for the elderly , also Lack of necessity .
3. Word cloud analysis wechat name which words 、 Expression packs are more popular
(1) Continue to use pyecharts
Generate word cloud
Core code :
# Data cleaning , Generate word cloud
def split_word(test_str):
test_str = re.sub('[,,.. \r\n]', '', test_str)
# jieba words
segment = jieba.lcut(test_str)
words_df = pd.DataFrame({
'segment': segment})
# quoting=3 Express stopwords.txt All the contents in are not quoted
stopwords = pd.read_csv(r"H:\PyCoding\ Analysis_wx_name\stopwords.txt", index_col=False, quoting=3, sep="\t", names=['stopword'], encoding='utf-8')
words_df = words_df[~words_df.segment.isin(stopwords.stopword)]
words_stat = words_df.groupby(by=['segment'])['segment'].agg({
" Count ": numpy.size})
words_stat = words_stat.reset_index().sort_values(by=[" Count "], ascending=False)
test = words_stat.head(200).values
codes = [test[i][0] for i in range(0,len(test))]
counts = [test[i][1] for i in range(0,len(test))]
wordcloud = WordCloud(width=1300, height=620)
wordcloud.add(" Wechat nickname ", codes, counts, word_size_range=[20, 100])
wordcloud.render('render_03.html')
Running effect :
(2) Use wordcloud
+matplotlib
Generate a higher level cloud of words
Core code :
# Let's talk about it next time matplotlib Drawing Visualization , That's interesting
# call get_name Function to get all wechat names
text = get_name()
# call jiebaclearText function , Data cleaning ( This function is the same as the above wordcutting idea )
text1=jiebaclearText(text)
# Create a cloud of words
bg = plt.imread(r"G:\small_pig.jpg")
# Generate the word cloud
wc=WordCloud(
background_color="wathet", # Set the background to white , Default is black
mask=bg, # Set the content range of word cloud ( All areas except the white area of the specified image will cover the content of the word cloud )
margin=10, # Set the edge of the picture
max_font_size=70, # Maximum font size displayed
random_state=20, # Return one... For each word PIL Color
font_path='G:\simkai.ttf' # Chinese processing , Use the font provided by the system
# You can download this font here :http://www.font5.com.cn/font_download.php?id=534&part=1245067666
).generate(text1)
# Set the font for the picture
my_font=fm.FontProperties(fname='G:\simkai.ttf')
# Picture background
bg_color = ImageColorGenerator(bg)
# Start drawing
plt.imshow(wc.recolor(color_func=bg_color))
# Remove the axis for the cloud image
plt.axis("off")
# Save the cloud
wc.to_file("render_04.png")
The outline of the word cloud :
Running effect :
Because the second method can't parse emoticons , So there's no expression , In addition, these two methods show almost the same content .
Through a cloud of words , We can see at a glance that you use the most , Apart from Chinese , It's the emoticon , Do you have any WeChat friends like thisRed lips
, Mine seems to have , Ha ha ha ~ When we just look at Chinese in the word cloud , Discovery imageThe sun
、The sun
、smile
、lovely
、Happy
、Love
、future
And other positive words are more popular , It also shows our inner positivity 、 optimistic , Of course, it's likeLily
、xu
、Chen
Wait for the name part , We also use a lot of nicknames , There is no lack of a resemblancesad
、cool
This is a cool word .
Four 、 Emotional analysis through nicknames ( The text comes from Zhihu netizens )
01 | Wechat nickname is all Chinese
Wechat nicknames in Chinese can be divided into two categories : Your real name and other nicknames .
People who use their own names as wechat nicknames directly , Character is mostly straight to the kind of , Treat people more candidly .
Their wechat is generally used for social contacts and daily work , Usually not casually add unfamiliar people , I'm not afraid to divulge personal information even with my real name , An inappropriate metaphor : Don't do the wrong thing , Not afraid of ghosts knocking at the door , Ha ha ha .
For other nicknames , Most of them have their own opinions , Maybe a nickname is a kind of expectation for the future , Maybe a nickname is an attitude to life , Or some nonsense , Cool words .( guess )
02 | Wechat nickname is all English
Out of personal preferences or work needs , Some people will give themselves an easy to remember 、 It's called Shunkou's English name , such as Sam、Abby、Jason, And often when I introduce myself , Let's call ourselves by English name .
For them , English name is equivalent to your second name , Use it as wechat name , It's not much different from the original name .
Some people try to avoid the common English names , Take something smaller , They are more concerned about improving their “ Forced case ”, Like to be innovative , The pursuit of fashion and avant-garde .
03 | Wechat nickname with emoticons
There are many girls who will add various emoticons to their wechat names , May be a love , A rose , A star , Or the system itself emoji expression .
They think this is a special decoration , Can make your name different from others .
Such a girl , Most of them have delicate and careful thinking 、 Romantic life sentiment , And a young girl's heart .
04 | Wechat nicknames are professional
Generally speaking , I will take the initiative to put a letter in front of my wechat name “A” Of , Most of them are wechat merchants or agents who advertise in the circle of friends all day .
More formal , Using all of these “ Company name + full name ” In the form of , This kind of people are basically salesmen or real estate agents ……
others , I will change my name suffix from time to time according to my different working stages .
Meet a friend who works as a human resource in a real estate company , In order to enjoy the holidays , She will change her wechat name to “ΧΧΧ On leave ”, In order to remind those who still privately mail her to ask about their work on holidays .
There are also some people coming in the opposite direction , In order to show that they are particularly positive , Change the wechat name to “ΧΧΧ Working overtime ”……emmm Mainly for the boss .
05 | Wechat nickname with idol name
Needless to say , These are all typical star chasers , And most of them are girls , For example, Mrs. Wu Yifan , Cai Xukun's secret girlfriend , Hu Ge's little wife …… No accident , Their heads are usually their idols .
They usually call idols on Weibo call, Friends circle will also send a lot of relevant recommendations , If someone praises his love beans , They will feel that they have met a confidant ; By contraries , If someone says they love beans , They'll pull black right away ……
Bear in mind , In front of the Star chaser , Don't give in easily , Tell her love beans what to do ……
06 | Wechat nickname is four words
Carefully observe the wechat names of elders , They will find that they especially like to use four words as nicknames .
What these four words have in common , It is a kind of quiet atmosphere of time :“ Life is like tea ”、“ Flowers are fragrant ”、“ As good as water ”、“ People are still ”“ clear ”……
Young people mark themselves with unique wechat names , The older aunts and uncles just want to place a pure ideal of life .
It's said that names are the second face of people . Good wechat name , It tends to make a better impression .
What's the meaning of your wechat name ? Let's talk in the comment area .
5、 ... and 、 appendix : Reference documents
(1) Wechat applet api Help document
(2) Wikipedia : Detailed explanation of the coding of expression
(3)Wordcloud Official documents
(4) It's written by AO Jiao's Paramecium Wordcloud Meaning of each parameter
(5) You know To whom
Written : Wechat name , Exposed what kind of person you are
Scan the code to generate an English name that suits you best
Welcome to WeChat official account. : The minimalist XksA, obtain Python/Java/ Front end and other learning resources !
边栏推荐
- How to use Moment. JS to check whether the current time is between 2 times
- Global and Chinese markets of electronic grade hexafluorobutadiene (C4F6) 2022-2028: Research Report on technology, participants, trends, market size and share
- Stc-b learning board buzzer plays music 2.0
- Global and Chinese market of maleic acid modified rosin esters 2022-2028: Research Report on technology, participants, trends, market size and share
- [oiclass] maximum formula
- 几款开源自动化测试框架优缺点对比你知道吗?
- 自动化测试中敏捷测试怎么做?
- How to do agile testing in automated testing?
- What are the software testing methods? Show you something different
- Investment operation steps
猜你喜欢
Cadence physical library lef file syntax learning [continuous update]
ucore lab7
Eigen User Guide (Introduction)
What are the commonly used SQL statements in software testing?
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
Want to change jobs? Do you know the seven skills you need to master in the interview software test
ucore lab7 同步互斥 实验报告
Capitalize the title of leetcode simple question
The minimum sum of the last four digits of the split digit of leetcode simple problem
MySQL数据库(四)事务和函数
随机推荐
MySQL数据库(一)
ucore lab1 系统软件启动过程 实验报告
C language do while loop classic Level 2 questions
Iterators and generators
基于485总线的评分系统
ucore lab8 文件系统 实验报告
ucore lab5
The number of reversing twice in leetcode simple question
基于485总线的评分系统双机实验报告
Introduction to variable parameters
安全测试入门介绍
Future trend and planning of software testing industry
CSAPP shell lab experiment report
JDBC introduction
Eigen User Guide (Introduction)
Video scrolling subtitle addition, easy to make with this technique
Interface test interview questions and reference answers, easy to grasp the interviewer
Build your own application based on Google's open source tensorflow object detection API video object recognition system (I)
What if software testing is too busy to study?
ucore lab 2