I'm new with Python and I'm using Twint. In order to create a DataFrame from the scraped twits, I must run the following code:
c = twint.Config()
c.Hide_output = output
twint.run.Search(c)
Tweets_df = twint.storage.panda.Tweets_df
The thing is that I don't understand what type of action is performing the twint.storage.panda.Tweets_df
line. It seems that it creates a DataFrame object. In fact, Tweets_df
is a pandas.core.frame.DataFrame
instance, but that's not the way (as far as I know) to create objects from a class. I mean: I was expecting to see that expression with parentheses; something like var = pd.DataFrame()
. So... what's going on?
Thank you very much
CodePudding user response:
in twint.storage.panda
Tweets_df is initially set to a None value it is likely that it is set to the value of a the object you're talking about at a later point in the code. So the code would look something like this.
#Our code module
data1 = None
class ourClass:
def __init__(self):
self.some_data = 0
data1 = ourClass()
then when we
import ourCode
variable = ourCode.data1
variable2 = ourCode.data1
we end up with variable and variable2 referencing the same object.
Link to twint source code
https://github.com/twintproject/twint/blob/master/twint/storage/panda.py