Category "pandas"

How to create and annotate a stacked proportional bar chart

I'm struggling to create a stacked bar chart derived from value_counts() of a columns from a dataframe. Assume a dataframe like the following, where responder i

How do I get list of all possible tickers (and also maybe their meanings) for various dataset libraries?

so the way I usually get some dataset (in this example, US Product Price Index) from econdb library is this: import datetime import pandas_datareader as pdr imp

Unable to read "#N/A" as string

I am having problem in reading "#N/A" as string. Tried using both "keep_default_na=False" and "na_filter = False". It is working out for "NA", "N/A", "#NA" but

pandas how to check dtype for all columns in a dataframe?

It seems that dtype only work for pandas.DataFrame.Series, right? Is there a function to display data types of all columns at once?

suppress Name dtype from python pandas describe

Lets say I have r = pd.DataFrame({'A':1 , 'B':pd.Series(1,index=list(range(4)),dtype='float32')}) And r['B'].describe()[['mean','std','min','m

Showing gps points on altair world map

I'm building (for learning purposes) a python program that extracts gps-data from *jpg files in a directory and display the gps-coordinates from the photo's on

Color pandas DataFrame value if larger than 1.5*median(column)

Let's say I have a DataFrame that looks like this: df= pd.DataFrame({'A': [1,-2,0,-1,17], 'B': [11,-23,1,-3,132], 'C': [121,

Cannot convert column values to binary values

Have this census datasheet, I'm trying to replace the values of column "Income" to either 1 or 0 (1 for ">50K", 0 for "<=50K") codes are as below, but I g

Python to convert different date formats in a column

I am trying to convert a column which has different date formats. For example: month 2018-01-01 float64 2018-02-01 float64 2018-03-01

pandas read_csv() method supports zip archive reading but not to_csv() method supports zip archive saving

Pandas 0.18 supports read_csv zip file as argument and reading zipped csv table correctly into data frame. But when i am trying to use to_csv() method to save d

How Do I Return a Different Value When Iterating Over a List of Lists

ISSUE I have a FOR loop that creates a list of lists where each entry consists of the input and associated output. I can't figure out how to iterate over the o

How to extract .zst files into a pandas dataframe

I'm a bit of a beginner when it comes to Python, but one of my projects from school needs me to perform classification algorithms on this reddit popularity data

How to plot a figure with Chinese Characters in label

When I draw a figure with Chinese Character label in Python 3, it doesn't work correctly: ] My code: fig = pd.DataFrame({ '债券收௡

add a column to data frame using pandas concatenation

I have "train_df" data frame which: print(train_df.shape) returns (997, 600). now I want to concatenate a column to this data frame which: print(len(local_

Python Pandas Group by date using datetime data

I have a column Date_Time that I wish to groupby date time without creating a new column. Is this possible the current code I have does not work. df = pd.group

Change the facecolor of boxplot in pandas

I need to change the colors of the boxplot drawn using pandas utility function. I can change most properties using the color argument but can't figure out how t

Modify code to capture values greater than - instead of exact match

The following code works well for identifying whether a value is hit or missed over following rows and giving the output column showing the time the condition w

Assign remainders to specific bins in pandas.qcut()

I am trying to replicate a specific method of attributing records into deciles, and there is the pandas.qcut() function which does a good job. My only concern i

How to handle response "None" from GeoPy client using Pandas apply?

I am working on pandas dataframe with quite a few hundreds addresses, trying to add a new column with coordinates received from geopy. Main question: how to han

Convert Points to Lines Geopandas

Hello I am trying to convert a list of X and Y coordinates to lines. I want to mapped this data by groupby the IDs and also by time. My code executes successful