Skip to content
Advertisement

Tag: pandas

how can i write comments on some cells of excel sheet using pandas

I didn’t find anything that enable me to write comments on some specific cell while writing excel sheet using panadas.to_excel . Any help is appreciated. Answer After searching for some time, I think the best way to handle comments or other such properties like color and size of text at cell or sheet level is to use XlsxWriter with pandas.

Pandas row to json

I have a dataframe in pandas and my goal is to write each row of the dataframe as a new json file. I’m a bit stuck right now. My intuition was to iterate over the rows of the dataframe (using df.iterrows) and use json.dumps to dump the file but to no avail. Any thoughts? Answer Pandas DataFrames have a to_json

How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?

I want to apply scaling (using StandardScaler() from sklearn.preprocessing) to a pandas dataframe. The following code returns a numpy array, so I lose all the column names and indeces. This is not what I want. A “solution” I found online is: It appears to work, but leads to a deprecationwarning: /usr/lib/python3.5/site-packages/sklearn/preprocessing/data.py:583: DeprecationWarning: Passing 1d arrays as data is deprecated in

Python fast DataFrame concatenation

I wrote a code to concatenate parts of a DataFrame to the same DataFrame as to normalize the occurrence of rows as per a certain column. and this is unbelievably slow. Is there a way to fast concatenate DataFrame without creating copies of it? Answer There are a couple of things that stand out. To begin with, the loop is

Advertisement