Skip to content

Tag: pandas

Read excel file in python using pandas

I am trying to read excel file in pycharm using pandas. I installed the package successfully. My issue is that I am trying to use file location in addition to its name I tried many thing as follow: However I keep receiving the following error Any Idea? Thanks in advance Answer Your fileLocation variable inclu…

Type hints for a pandas DataFrame with mixed dtypes

I’ve been looking for robust type hints for a pandas DataFrame, but cannot seem to find anything useful. This question barely scratches the surface Pythonic type hints with pandas? Normally if I want to hint the type of a function, that has a DataFrame as an input argument I would do: What I cannot seem…

Datetime object in DataFrame with just time

This is the plain column And the I would like to put that column in the index, the problem is when I try to use the method resample() I always get the same problem: TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of ‘Index’ I’ve been using this to…

INSERT INTO SELECT based on a dataframe

I have a dataframe df and I want to to execute a query to insert into a table all the values from the dataframe. Basically I am trying to load as the following query: For that I have the following code: However, I am getting the following error: Does anyone know what I am doing wrong? Answer See below my

Importing data from URL using Python (into pandas dataframe)?

I’ve gone around in circles on this one. A bit frustrating as the solution is probably close at hand. Anyway, I found a URL that returns some data in CSV format. However, the URL itself does not contain the csv file name. In a web browser, I can easily go to the link and them I’m asked whether I w…