Beispiel #1
0
df.ix[0]
'# 结束----------------------------'

'csv_data = pd.read_csv(self.file_path, encoding='GB18030')'
'''encoding设置编码格式,即使有中文的表头,也不必设置,设置了中文字符集反而会有问题'''
'# 结束----------------------------'

''.'.join(list)'
'''.号把List里面的字符串起来'''
list = ['a', 'b']
'.'.join(list)
'# 结束----------------------------'

'pd.plot(title="XXX", xlim=(0, 10000), ylim=(-30, 100), secondary_y=["VehSpd"])'
'''用dataframe画图,以dataframe index为横坐标,其他列作纵坐标画出曲线系,secondary_y可以设置画在第二个y轴的列'''
pd.set_index("Time")  # 用某一列作为dataframe的index
'# 结束----------------------------'

'function(**dict)----------------------------'
'''把关键字参数用字典的形式包装传给函数'''
'# 结束----------------------------'

'MODEL.objects.filter(**dict)----------------------------'
'''把sql参数用字典的形式包装传给spl语句'''
'# 结束----------------------------'

'reshape(-1,1)----------------------------'
'''ndarraay每个元素撞到一个ndarray中'''
'# 结束----------------------------'

'pd.get_dummies(df)----------------------------'
import pandas as pd
import country_converter as coco
pd = pd.read_csv('Emissions_with_ISO3.csv')
pd = pd.set_index('ISO3')
pd = pd.rank(ascending=False).reset_index()
pd.to_csv('emissions_rankings.csv')
X = X.rename(columns={"OpinionEquilibriumBot": "OpinionEquilibrium"})
df_nobot = df_nobot.append(X)
#get node degrees in observed network
X = []
for sd in list(Gbot.in_degree()):
    x = {"ScreenName": sd[0], "in_degree": sd[1]}
    X.append(x)
Din = pd.DataFrame(X)
X = []
for sd in list(Gbot.out_degree()):
    x = {"ScreenName": sd[0], "out_degree": sd[1]}
    X.append(x)
Dout = pd.DataFrame(X)
df_degree = pd.merge(Din, Dout, on="ScreenName", how="inner")

df.set_index('ScreenName')
df_bot.set_index('ScreenName')
df_nobot.set_index('ScreenName')

#df_bot.to_csv(path_data+"df_bot.csv")
#df_nobot.to_csv(path_data+"df_nobot.csv")

df_bot = pd.merge(df, df_bot, on="ScreenName", how="inner")
df_bot = pd.merge(df_degree, df_bot, on="ScreenName", how="inner")
df_assess = pd.merge(df_bot, df_nobot, on="ScreenName")

df_assess = df_assess[[
    "ScreenName", "OpinionNeuralNet", "OpinionEquilibriumBot",
    "OpinionEquilibrium", "Bot", "Stubborn", "Rate", "friend_count",
    "follower_count", "in_degree", "out_degree"
]]