Category "pandas"

How to convert the values of an attribute having categorical values to integer type?

I have a dataset in which one of its columns is Ex-Showroom_Price, and I'm trying to convert its values to integers but I'm getting an error. import pandas as p

Postgres 9.5 upsert command in pandas or psycopg2?

Most of the examples I see are people inserting a single row into a database with the ON CONFLICT DO UPDATE syntax. Does anyone have any examples using SQLAlch

pandas installation error using pip installer

I am getting following error repeatedly while installing pandas through pip installer for python 3.7 in command prompt Using cached https://files.pythonhosted.

What is the difference between `pandas.Series.ravel()`, `pandas.Series.to_numpy()`, `pandas.Series.values` and `pandas.Series.array`?

Basically the title sums it up. I have created a dummy pandas.Series object and looked up all these properties and methods. Documentation states that all of the

Overwrite columns in DataFrames of different sizes pandas

I have following two Data Frames: df1 = pd.DataFrame({'ids':[1,2,3,4,5],'cost':[0,0,1,1,0]}) df2 = pd.DataFrame({'ids':[1,5],'cost':[1,4]}) And I want to upd

Python:Pandas - Object to string type conversion in dataframe

I'm trying to convert object to string in my dataframe using pandas. Having following data: particulars NWCLG 545627 ASDASD KJKJKJ ASDASD TGS/ASDWWR42045645010

Dropping df 's rows inside an iterrows() function does'nt work

I have a pandas dataframe df1 and I want to create a new df2 with columns created from df1 's rows values : DAT_RUN DAT_FORECAST LIB_SOURCE TEMPERATURE_

How to save a new sheet in an existing excel file, using Pandas?

I want to use excel files to store data elaborated with python. My problem is that I can't add sheets to an existing excel file. Here I suggest a sample code to

How to create dictionary to look for dropped zeros?

I ran into this specific problem where I have a dataframe of ID numbers. Some of these account numbers have dropped leading zeros. dataframe is df. ID 345 345 5

Why has seaborn/matplotlib filled below the line in this lineplot

I don't know why my plot looks like this: I only want to display lines with no fill. Code below. Note this also happens if I run in Spyder or cmd. import ma

Remove one out of two legends from Seaborn Scatterplot

Using the 'tips' dataset as a toy model, I generate the following plot: import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset("tips")

Word count Matrix of document corpus with Pandas Dataframe

Well, I have a corpus of 2000+ text documents and I'm trying to make a matrix with pandas dataframe in the most elegant way. The matrix would look like this: d

Python_OSError: [Errno 28] No space left on device

I have the following error while exporting pandas dataframe into csv file. I have enough space in my hard disk. OSError: [Errno 28] No space left on device

pandas - filter on groups which have at least one column containing non-null values in a groupby

I have the following python pandas dataframe: df = pd.DataFrame({'Id': ['1', '1', '1', '2', '2', '3'], 'A': ['TRUE', 'TRUE', 'TRUE', 'TRUE', 'TRUE', 'FALSE'],

Streamlit Panda Query Function Syntax Error When Finding Column in CSV Dataframe

When Using Streamlit to build a data interface getting a syntax error. My downloaded csv dataframe has a column 'NUMBER OF PERSONS INJURED', after converting i

How do I read SQL stored procedure data through pyodbc and get results into a dataframe?

I have a stored proc in SQL Server called test.storedproc My py script is as follows import pyodbc import pandas as pd conn = pyodbc.connect('Driver={SQL Server

Plot elapsed time on x axis using date indexed time-series data

In my pandas dataframe, my time series data is indexed by absolute time (a date of format YYYY-MM-DD HH24:MI:SS.nnnnn): 2017-01-04 16:25:25.143493 58 2017-0

how to assign an entire list to each row of a pandas dataframe

I have a dataframe and a list df = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6]}) mylist= [10,20,30,40,50] I would like to have a list as element in each row of a

Convert numpy array from space separated to comma separated in python

This is data in .csv format file generally we expect array/ list with [1,2,3,4] comma separated values which it seems that nothing happened in this case data =

Pandas(Python) : Fill empty cells with with previous row value?

I want to fill empty cells with with previous row value if they start with number. For example, I have Text Text 30 Text Text