Top "Pandas" questions

Pandas is a Python library for data manipulation and analysis, e.g. dataframes, multidimensional time series and cross-sectional datasets commonly found in statistics, experimental science results, econometrics, or finance.

How to convert index of a pandas dataframe into a column?

This seems rather obvious, but I can't seem to figure out how to convert an index of data frame to …

python pandas dataframe
pandas: filter rows of DataFrame with operator chaining

Most operations in pandas can be accomplished with operator chaining (groupby, aggregate, apply, etc), but the only way I've found …

python pandas dataframe
Count unique values with pandas per groups

I need to count unique ID values in every domain I have data ID, domain 123, 'vk.com' 123, 'vk.com' 123, 'twitter.…

python pandas group-by unique pandas-groupby
pandas create new column based on values from other columns / apply a function of multiple columns, row-wise

I want to apply my custom function (it uses an if-else ladder) to these six columns (ERI_Hispanic, ERI_AmerInd_…

python pandas numpy apply
Selecting with complex criteria from pandas.DataFrame

For example I have simple DF: import pandas as pd from random import randint df = pd.DataFrame({'A': [randint(1, 9) for …

python pandas
Extracting just Month and Year separately from Pandas Datetime column

I have a Dataframe, df, with the following column: df['ArrivalDate'] = ... 936 2012-12-31 938 2012-12-29 965 2012-12-31 966 2012-12-31 967 2012-12…

python pandas
Convert floats to ints in Pandas?

I've been working with data imported from a CSV. Pandas changed some columns to float, so now the numbers in …

python pandas floating-point integer dataset
How to reset index in a pandas dataframe?

I have a dataframe from which I remove some rows. As a result, I get a dataframe in which index …

python indexing pandas dataframe
Selecting/excluding sets of columns in pandas

I would like to create views or dataframes from an existing dataframe based on column selections. For example, I would …

python pandas dataframe
Convert columns to string in Pandas

I have the following DataFrame from a SQL query: (Pdb) pp total_rows ColumnID RespondentCount 0 -1 2 1 3030096843 1 2 3030096845 1 and I want to …

python pandas string type-conversion