Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Twint
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Twint
Commits
dd5aaaba
Commit
dd5aaaba
authored
Jun 03, 2018
by
Francesco Poldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished Pandas storing
parent
b13299a0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
twint/Pandas.py
twint/Pandas.py
+21
-14
No files found.
twint/Pandas.py
View file @
dd5aaaba
import
pandas
as
pd
import
warnings
from
time
import
strftime
,
localtime
from
time
import
strftime
,
localtime
import
pandas
as
pd
from
.elasticsearch
import
*
from
.elasticsearch
import
*
_blocks
=
[]
_blocks
=
[]
def
update
(
Tweet
,
session
):
def
update
(
Tweet
,
session
):
day
=
weekday
(
strftime
(
"
%
A"
,
localtime
(
Tweet
.
datetime
)))
day
=
weekday
(
strftime
(
"
%
A"
,
localtime
(
Tweet
.
datetime
)))
dt
=
"{} {}"
.
format
(
Tweet
.
datestamp
,
Tweet
.
timestamp
)
dt
=
"{} {}"
.
format
(
Tweet
.
datestamp
,
Tweet
.
timestamp
)
...
@@ -32,27 +32,34 @@ def get():
...
@@ -32,27 +32,34 @@ def get():
df
=
pd
.
DataFrame
(
_blocks
)
df
=
pd
.
DataFrame
(
_blocks
)
return
df
return
df
def
save
(
_dataframe
,
_dataname
,
_filename
,
_type
):
def
save
(
_filename
,
_dataframe
,
**
options
):
if
not
_dataname
:
if
options
.
get
(
"dataname"
):
_dataname
=
options
.
get
(
"dataname"
)
else
:
_dataname
=
"twint"
_dataname
=
"twint"
if
not
_type
or
_type
==
"HDF5"
:
if
not
options
.
get
(
"type"
):
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
)
_store
=
pd
.
HDFStore
(
_filename
)
_store
=
pd
.
HDFStore
(
_filename
)
_store
[
_dataname
]
=
_dataframe
_store
[
_dataname
]
=
_dataframe
elif
_type
==
"Pickle"
:
_store
.
close
()
elif
options
.
get
(
"type"
)
==
"Pickle"
:
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"ignore"
)
_dataframe
.
to_pickle
(
_filename
)
_dataframe
.
to_pickle
(
_filename
)
else
:
else
:
print
(
"Please specify:
DataFrame, DataFrame name, file
name and type (HDF5, default, or Pickle"
)
print
(
"Please specify:
filename, DataFrame, DataFrame
name and type (HDF5, default, or Pickle"
)
def
read
(
_
dataframe
,
_dataname
,
_filename
,
_type
):
def
read
(
_
filename
,
**
options
):
if
not
_dataname
:
if
not
options
.
get
(
"dataname"
)
:
_dataname
=
"Twint"
_dataname
=
"Twint"
if
not
_type
or
_type
==
"HDF5"
:
if
not
options
.
get
(
"type"
)
:
_store
=
pd
.
HDFStore
(
_filename
)
_store
=
pd
.
HDFStore
(
_filename
)
df
=
_store
[
_dataname
]
df
=
_store
[
_dataname
]
return
df
return
df
elif
_type
==
"Pickle"
:
elif
options
.
get
(
"type"
)
==
"Pickle"
:
df
=
pd
.
read_pickle
(
_filename
)
df
=
pd
.
read_pickle
(
_filename
)
return
df
return
df
else
:
else
:
...
...
Write
Preview
Markdown
is supported
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