Sometimes when you create a data frame, some of the columns may be of mixed type. And you might see warning like this DtypeWarning: Columns (0) have mixed types. Specify dtype option on import or set low_memory=False. We get this error when Pandas tries to guess the type for each element of a column. For […]
Python
How to Collapse Multiple Columns in Pandas? Groupby with Dictionary
Often you may want to collapse two or multiple columns in a Pandas data frame into one column. For example, you may have a data frame with data for each year as columns and you might want to get a new column which summarizes multiple columns. One may need to have flexibility of collapsing columns […]
How To Convert a Column to Row Name/Index in Pandas?
Pandas has a method set_index to covert a column in Pandas dataframe into rowname or row index. Let us see an example of converting a column name into rowname in Pandas. Let us load pandas as “pd”. Let us use real-world gapminder data from vega_datasets. Convert a Column to Row Name Let us convert the […]
How To Split A Column or Column Names in Pandas and Get Part of it?
Often you may want to create a new variable either from column names of a pandas data frame or from one of the columns of the data frame. Just like Python, Pandas has great string manipulation abilities that lets you manipulate strings easily. Let us see an example of using Pandas to manipulate column names […]
Plotnine: A Python library to use ggplot2 in Python
Python’s visualization options can be difficult to grasp, if you recently moved to use Python after using R for a while. There are a lot of options. Multiple options for visualizations are good. Especially, mature matplotlib, Seaborn, Bokeh and the new library like Altair are great to learn and use for data visualization in Python. […]