Reputation:
I'm appending some weather data (from json- dict) - in Japanese to DataFrame.
I would like to have something like this
天気 風
0 状態: Clouds 風速: 2.1m
1 NaN 向き: 230
But I have this
天気 風
0 状態: Clouds NaN
1 NaN 風速: 2.1m
2 NaN 向き: 230
How Could I change the Codes to make it like that? Here is the code
df = pd.DataFrame(columns=['天気','風'])
df = df.append({'天気': weather_status}, ignore_index=True) # 状態: Clouds - value
df = df.append({'風': wind_speed}, ignore_index=True) # 風速: 2.1m -value
df = df.append({'風': wind_deg}, ignore_index=True) # 向き: 230 -value
print(df)
Upvotes: 5
Views: 750
Reputation: 71570
One way could be:
df = pd.DataFrame(columns=['天気','風'])
df = df.append({'天気': weather_status, '風': wind_speed}, ignore_index=True)
df = df.append({'風': wind_deg}, ignore_index=True)
print(df)
And print without index
print(df.to_string(index=False))
Upvotes: 2