I have 100 url and when I click it, it will show json file.
But the json file is a little bit complicated, it looks like this:
{
"release": [
{
"id":"1234",
"version":"1.0",
"releaseDate":"2023-07-31",
"xxx": "ssss",
"yyy": "uuuu" }
{
"id" :"2345",
"version": "1.1"
"releaseDate":"2023-05-12"
"xxx":"sssss"
.....}
],
"user":false
}
I want to count the release for past 6 month, but the complicated json makes the popular json.loads…pd.read_json…normalize…doesnot work
also the …. actually contains some html label like below, so it will be better to just select the "releaseDate" to filter.
"att":"<p><em>as Alice</em> for.....
What I tried
I can use this to count the release for all time
releases=len(json_data['releases'])
but how can I limit it to the past 6 month?
any help is really appreciated!!
2
Answers
Create a string that contains the date from six months ago:
And then use
len()
with a list comprehension that only chooses items that were released on or after that date:Consider this example:
Prints:
Then to filter this dataframe you can do:
Prints: