python-for-data-and-media-communication-gitbook
python-for-data-and-media-communication-gitbook copied to clipboard
Feedbacks for Note11
- The output for this piece of code is not the same with the DEFAULT
迷茫
Note 12:
First, I tried to draw the graph using nx.show(g)
Nothing happened
Then, I added plt.show(), and I got this
This is weird because there are only three nodes in my graph I tried to restart and run again, but the result was the same @hupili @ChicoXYC
This problem was also solved. It turns out that I typed nx.show(g)
twice.
You are right. If we use print()
, the output will drop its type traits to get a better effect of display on the screen. Just use dt_1,dt_2,dt_3,dt_4
without print()
in the last line to get the same result in this note. I will revise this point.
Note 12: First, I tried to draw the graph using nx.show(g) Nothing happened
I tried to restart and run again, but the result was the same @hupili @ChicoXYC
@SerenaQYHuang please try separate the following two lines into two cells.
g.add_edge('A','B')
nx.draw(g)
@SerenaQYHuang @ChicoXYC , please redirect the week 12 to another thread. It is better the keep the topic focused in one issue.
@FLYSTEPHEN , I think the OP may be asking the function of "default" --- i.e. when there is any datetime dimentions (year/ month/ ...) missing, the parser will use default in that place. We can elaborate this in the notes.
@SerenaQYHuang , can you further elaborate the question? Which part is confusing? You can also check if this PR solves your problem.
@hupili The problem is solved. I was confused by the format of the result because it did not match the DEFAULT but @FLYSTEPHEN has pointed out that it was because I used the function print()
.
@hupili 's comment is also right. We need to explain the function of default
here. I will add it later
Other feedbacks in Chapter 11
-
In the A failed parsing case There are Chinese characters in
parse("2月15日 10:36:28")
, and then it failed. I didn't find solution in references, I guess add it in notebook will be better. -
In the Add timedelta to a datetime object The sample code seem has error, and I run below code successfully.
-
In the Resample, aggregate and plot I try to read csv by link in this notebook, but there will be error. Although I copied and pasted the link in Chrome, there was 404 error.
@ConnorLi96 the link in the notebook you give is outdated, the csv in the notes is the newest. But the strange thing is that I still cannot open this csv with the following error:
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>
The alternative solution:
import pandas as pd
import io
import requests
url="https://raw.githubusercontent.com/hupili/python-for-data-and-media-communication/master/text-analysis/regular_reader_tweets.csv"
s=requests.get(url).text
df=pd.read_csv(io.StringIO(s))
@hupili do you know this, sir?
talked about this during class. It is likely to be CVA problem. That is why in the class demo of week07, I download the data from GitHub, instead of directly loading via URL
@hupili But it is strange, because Windows users can directly load csv with this way in CVA.
This can be recorded in FAQ. Just collect those incidences and conclude the pattern. One system work does not carry on to other systems. So is it like Python version. The pattern may be
CVA not working
or CVA+MAC not working
or CVA+MAC+requests not working
—-
besides detailed Python version, requests version also matter.
Also, the key can be Windows or can be Anaconda v.s. bate Python.
@ConnorLi96 You are right.
- For point 1
In the A failed parsing case
There are Chinese characters in parse("2月15日 10:36:28"), and then it failed. I didn't find solution in references, I guess add it in notebook will be better.
I still want to stay concise so I add a pointer below the code.
- For point 2
In the Add timedelta to a datetime object
The sample code seem has error, and I run below code successfully.
This is because I import the whole library this time. I will turn back to just import the sub-functions, in case confusing our readers.
- For point 3
In the Resample, aggregate and plot
I try to read csv by link in this notebook, but there will be error. Although I copied and pasted the link in Chrome, there was 404 error.
I think this is because the file's location has been changed. @hupili Where is the csv now, sir? I can revise it.
@FLYSTEPHEN , file location can refer to this comment