Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Meurou
NF26 Project
Commits
ec24abd2
Commit
ec24abd2
authored
Jun 22, 2019
by
Tianyang
Browse files
Change database1
parent
57136175
Changes
4
Hide whitespace changes
Inline
Side-by-side
.DS_Store
View file @
ec24abd2
No preview for this file type
countDtata.py
deleted
100644 → 0
View file @
57136175
import
cassandra.cluster
def
countData
(
database
,
session
):
years
=
[
i
for
i
in
range
(
2008
,
2018
)]
for
year
in
years
:
count
=
0
number
=
session
.
execute_async
(
"select year from caitiany.%s where year = %d ALLOW FILTERING"
%
(
database
,
year
))
for
row
in
number
.
result
():
count
+=
1
print
(
year
,
' has '
,
count
,
' datas.
\n
'
)
if
__name__
==
"__main__"
:
cluster
=
cassandra
.
cluster
.
Cluster
([
'localhost'
])
session
=
cluster
.
connect
(
'caitiany'
)
countData
(
'database_espace'
,
session
)
\ No newline at end of file
database_pre1.py
View file @
ec24abd2
...
...
@@ -14,7 +14,7 @@ def databaseCreate_Q1(session):
CREATE TABLE database_espace (
station varchar,
year int,
season
varchar
,
season
int
,
month int,
day int,
hour int,
...
...
@@ -64,13 +64,13 @@ def load_data(filename):
time
=
match_time
.
groupdict
()
#add season
if
3
<=
int
(
time
[
"month"
])
<=
5
:
r
[
"season"
]
=
"Spring"
r
[
"season"
]
=
0
elif
6
<=
int
(
time
[
"month"
])
<=
8
:
r
[
"season"
]
=
"Summer"
r
[
"season"
]
=
1
elif
9
<=
int
(
time
[
"month"
])
<=
11
:
r
[
"season"
]
=
"Autumn"
r
[
"season"
]
=
2
elif
int
(
time
[
"month"
])
in
(
12
,
1
,
2
):
r
[
"season"
]
=
"Winter"
r
[
"season"
]
=
3
else
:
continue
...
...
@@ -81,7 +81,7 @@ def load_data(filename):
data
=
{}
data
[
"station"
]
=
r
[
"station"
]
data
[
"year"
]
=
int
(
time
[
"year"
])
data
[
"season"
]
=
r
[
"season"
]
data
[
"season"
]
=
int
(
r
[
"season"
]
)
data
[
"month"
]
=
int
(
time
[
"month"
])
data
[
"day"
]
=
int
(
time
[
"day"
])
data
[
"hour"
]
=
int
(
time
[
"hour"
])
...
...
question1.py
View file @
ec24abd2
...
...
@@ -114,6 +114,14 @@ def drawCourbe_history(session,time,target,timeNB,targetNB,espace):
each
=
list
(
each
)
if
timeNB
==
2
:
each
[
0
]
=
str
(
each
[
0
])
if
each
[
1
]
==
0
:
each
[
1
]
=
"Spring"
elif
each
[
1
]
==
1
:
each
[
1
]
=
"Summer"
elif
each
[
1
]
==
2
:
each
[
1
]
=
"Autumn"
elif
each
[
1
]
==
3
:
each
[
1
]
=
"Winter"
keys
[
index_each
]
=
"."
.
join
(
each
)
elif
timeNB
==
3
:
each
[
0
]
=
str
(
each
[
0
])
...
...
@@ -170,6 +178,14 @@ def drawCourbe_season(session,season,target,targetNB,espace):
index_each
=
keys
.
index
(
each
)
each
=
list
(
each
)
each
[
0
]
=
str
(
each
[
0
])
if
each
[
1
]
==
0
:
each
[
1
]
=
"Spring"
elif
each
[
1
]
==
1
:
each
[
1
]
=
"Summer"
elif
each
[
1
]
==
2
:
each
[
1
]
=
"Autumn"
elif
each
[
1
]
==
3
:
each
[
1
]
=
"Winter"
keys
[
index_each
]
=
"."
.
join
(
each
)
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
...
...
@@ -196,6 +212,14 @@ def drawCourbe_season(session,season,target,targetNB,espace):
#Choose the data of the season we want
def
seprateSeason
(
results
,
season
):
output
=
dict
()
if
season
==
"Spring"
:
season
=
0
elif
season
==
"Summer"
:
season
=
1
elif
season
==
"Autumn"
:
season
=
2
elif
season
==
"Winter"
:
season
=
3
for
each
in
results
:
if
season
in
each
:
output
[
each
]
=
results
[
each
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment