Difference between revisions of "Python, Excel Individual Commands"
Jump to navigation
Jump to search
(Created page with "==Creating a pie chart from data== import plotly.express as px ## pip install plotly fig = px.pie(active_posts'username', 'Messages posted', values='Messages posted', n...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
fig = px.pie(active_posts[['username', 'Messages posted']], values='Messages posted', names='username') | fig = px.pie(active_posts[['username', 'Messages posted']], values='Messages posted', names='username') | ||
fig.show() | fig.show() | ||
''' active_posts has the data, username is a column also messages posted'' | ''' active_posts has the data, username is a column also messages posted''' | ||
==Sorting Data Output== | |||
'''Sorting in ascending order''' | |||
df.sort_values(by=['Brand'], inplace=True) | |||
'''Sorting in Descending order''' | |||
df.sort_values(by=['Brand'], inplace=True, ascending=False) | |||
'''Sort multiple columns''' | |||
df.sort_values(by=['Year','Price'], inplace=True) | |||
==[[#top|Back To Top]] - [[Python|Main Category]]/[[Python_Excel_Related| Excel Category]]== | ==[[#top|Back To Top]] - [[Python|Main Category]]/[[Python_Excel_Related| Excel Category]]== | ||
[[Category:Python]] | [[Category:Python]] |
Latest revision as of 18:29, 11 September 2020
Creating a pie chart from data
import plotly.express as px ## pip install plotly fig = px.pie(active_posts'username', 'Messages posted', values='Messages posted', names='username') fig.show()
active_posts has the data, username is a column also messages posted
Sorting Data Output
Sorting in ascending order
df.sort_values(by=['Brand'], inplace=True)
Sorting in Descending order
df.sort_values(by=['Brand'], inplace=True, ascending=False)
Sort multiple columns
df.sort_values(by=['Year','Price'], inplace=True)