Skip to main content

All Questions

Tagged with
-7 votes
0 answers
37 views

> AttributeError: 'float' object has no attribute 'items' [closed]

I've read many posts on this site but not yet posted so I apologize for first-timer mistakes. I'm writing a class that has created a pandas dataframe to store information about an instance of the ...
Virginia B's user avatar
-1 votes
1 answer
25 views

Run a dataframe of URLs through a function - Python

I am trying to use a dataframe that contains a bunch of URLs and run each individual URL through a function. Note: the function works perfectly if called with a single URL i.e. myfunction(https://www....
htank's user avatar
  • 21
0 votes
0 answers
41 views

Why does `groupby` return fewer rows than the number of unique rows after removing duplicates? [duplicate]

I'm working with a DataFrame df and trying to understand why the result of a groupby operation has fewer rows than expected. Here's what I did: columnas = ["description", "surface_total&...
invalid syntax's user avatar
0 votes
0 answers
42 views

Apply float styling to specific rows in pandas dataframe

I've created a large dataframe with a smaller dataframe that represents a summary of some calculations run on the larger dataframe. This will find certain percentages, max/min of some columns, etc. I'...
Mwa's user avatar
  • 1
0 votes
1 answer
46 views

Why does pd.to_datetime('2025175', format='%Y%W%w') and pd.Timestamp.fromisocalendar(2025, 17, 5) gives different output? [duplicate]

Why does pd.to_datetime('2025175', format='%Y%W%w') and pd.Timestamp.fromisocalendar(2025, 17, 5) gives different output? I expected to obtain Timestamp('2025-04-25 00:00:00') for both cases. But the ...
viniciusrf1992's user avatar
0 votes
2 answers
48 views

Splitting the time dimension of nc data using xarray

Now I have a timelonlat 3D data where time is recorded as year, month and day. I need to split time in the form of year*month+day. So that the data becomes 4 dimensional. How should I do this? I have ...
Breeze's user avatar
  • 372
-3 votes
0 answers
63 views

When trying to index from a series, why it just showed one element instead of one row?

I am working on a python practice. I am trying to filter out which occupation has the lowest average sleeping duration from data csv. Here is example code. import pandas as pd sleep_data = pd.read_csv(...
Dason Lau's user avatar
2 votes
2 answers
62 views

Pandas: Fill in missing values with an empty numpy array

I have a Pandas Dataframe that I derive from a process like this: df1 = pd.DataFrame({'c1':['A','B','C','D','E'],'c2':[1,2,3,4,5]}) df2 = pd.DataFrame({'c1':['A','B','C'],'c2':[1,2,3],'c3': [np.array((...
cbw's user avatar
  • 289
1 vote
1 answer
83 views

DtypeWarning: Columns have mixed types error in Pandas when loading csv [duplicate]

When loading a csv file in pandas I've encountered the bellow error message: DtypeWarning: Columns have mixed types. Specify dtype option on import or set low_memory=False Reading online I found ...
MariaT's user avatar
  • 75
0 votes
0 answers
51 views

Doesn't imputing missing values affect the data quality? [closed]

I'm doing multiple linear regression for a dataset. The numeric_df dataframe is the continuous variables in the orignal dataframe. I want to check linearity between the price variable (target) and the ...
ssmalik's user avatar
  • 25
-1 votes
1 answer
53 views

Convert nested python dict to a pandas dataframe

I have weather data in a python dict that I'm trying to convert to a pandas df. (From there I'll load it into SQLServer but I've got that part working) my_dict = { 'data.outdoor.temperature': {'unit':...
Jim's user avatar
  • 3
0 votes
1 answer
60 views

Apply different aggregate functions to different columns of a pandas dataframe, and run a pivot/crosstab?

The issue In SQL it is very easy to apply different aggregate functions to different columns, e.g. : select item, sum(a) as [sum of a], avg(b) as [avg of b], min(c) as [min of c] In Python, not so ...
Pythonista anonymous's user avatar
0 votes
0 answers
41 views

pandas column based on multiple values from other columns [duplicate]

I have a dataframe df = pd.DataFrame(data={ 'a':[1,2,3,4,1,2,3,4,5], 'b':[1,4,2,2,1,2,1,1,2], 'c':[1000, 10, 500, 100,100, 10, 500, 100, 10] }) which looks like a b c 0 1 1 ...
Nikko Cleri's user avatar
1 vote
1 answer
56 views

Optimum selection mechanism when choosing relevant rows from a dataframe

I have a large Excel spreadsheet. I'm only interested in certain columns. Furthermore, I'm only interested in rows where specific columns meet certain criteria. The following works: import pandas as ...
Adon Bilivit's user avatar
  • 27.8k
-2 votes
0 answers
78 views

How to fill missing as 0 where the dataset contains data outside the table and has multi-header for some columns too without affecting them [closed]

How to fill missing as 0 where the dataset contains data outside the table and has multi-header for some columns too without affecting the data outside the table and the multi-headers? I need to fill ...
Padmaganth Karthikeyan's user avatar

15 30 50 per page
1
2 3 4 5
16622