Sayth Renshaw writes:
>>
>> That actually creates another error.
>>
>> A value is trying to be set on a copy of a slice from a DataFrame.
>> Try using .loc[row_indexer,col_indexer] = value instead
>>
>> See the caveats in the documentation:
>> http://pandas.pydata.org/pandas-docs/stable/indexi
On Tuesday, 10 September 2019 12:56:36 UTC+10, Sayth Renshaw wrote:
> On Friday, 6 September 2019 07:52:56 UTC+10, Piet van Oostrum wrote:
> > Piet van Oostrum <> writes:
> >
> > > That would select ROWS 0,1,5,6,7, not columns.
> > > To select columns 0,1,5,6,7, use two-dimensional indexes
> > >
On Friday, 6 September 2019 07:52:56 UTC+10, Piet van Oostrum wrote:
> Piet van Oostrum <> writes:
>
> > That would select ROWS 0,1,5,6,7, not columns.
> > To select columns 0,1,5,6,7, use two-dimensional indexes
> >
> > df1 = df.iloc[:, [0,1,5,6,7]]
> >
> > : selects all rows.
>
> And that also
That is actually consistent with Excel row, column. Can see why it works that
way then.
Thanks
--
https://mail.python.org/mailman/listinfo/python-list
Piet van Oostrum writes:
> That would select ROWS 0,1,5,6,7, not columns.
> To select columns 0,1,5,6,7, use two-dimensional indexes
>
> df1 = df.iloc[:, [0,1,5,6,7]]
>
> : selects all rows.
And that also solves your original problem.
This statement:
df1['Difference'] = df1.loc['Current Team']
Sayth Renshaw writes:
> On Sunday, 1 September 2019 10:48:54 UTC+10, Sayth Renshaw wrote:
>> I've created a share doc same structure anon data from my google drive.
>>
>> https://drive.google.com/file/d/0B28JfFTPNr_lckxQRnFTRF9UTEFYRUVqRWxCNVd1VEZhcVNr/view?usp=sharing
>>
>> Sayth
>
> I tried
On Sunday, 1 September 2019 10:48:54 UTC+10, Sayth Renshaw wrote:
> I've created a share doc same structure anon data from my google drive.
>
> https://drive.google.com/file/d/0B28JfFTPNr_lckxQRnFTRF9UTEFYRUVqRWxCNVd1VEZhcVNr/view?usp=sharing
>
> Sayth
I tried creating the df1 dataframe by usin
I've created a share doc same structure anon data from my google drive.
https://drive.google.com/file/d/0B28JfFTPNr_lckxQRnFTRF9UTEFYRUVqRWxCNVd1VEZhcVNr/view?usp=sharing
Sayth
--
https://mail.python.org/mailman/listinfo/python-list
On Sunday, 1 September 2019 05:19:34 UTC+10, Piet van Oostrum wrote:
> Sayth Renshaw writes:
>
> > But on both occasions I receive this error.
> >
> > # KeyError: 'the label [Current Team] is not in the [index]'
> >
> > if I test df1 before trying to create the new column it works just fine.
> >
Sayth Renshaw writes:
> But on both occasions I receive this error.
>
> # KeyError: 'the label [Current Team] is not in the [index]'
>
> if I test df1 before trying to create the new column it works just fine.
>
What do you mean by testing df1?
And could it be that 'Current Team' is spelled diff
Sayth Renshaw writes:
>
> I have tried both
>
> df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')]
> df1['Difference'] = df1.loc['Current Team'].str.lower().str.strip() ==
> df1.loc['New Team'].str.lower().str.strip()
>
> and
>
> df1 = df[['UID','Name','New Leader','Current
On Friday, 30 August 2019 00:49:32 UTC+10, Piet van Oostrum wrote:
> Piet van Oostrum writes:
>
> > So the correct way to do this is to make df1 a copy rather than a view.
> >
> > df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')]
>
> Or maybe even make an explicit copy:
>
On Friday, 30 August 2019 00:49:32 UTC+10, Piet van Oostrum wrote:
> Piet van Oostrum
>
> > So the correct way to do this is to make df1 a copy rather than a view.
> >
> > df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')]
>
> Or maybe even make an explicit copy:
>
> df1 =
Piet van Oostrum writes:
> So the correct way to do this is to make df1 a copy rather than a view.
>
> df1 = df.loc[:, ('UID','Name','New Leader','Current Team', 'New Team')]
Or maybe even make an explicit copy:
df1 = df[['UID','Name','New Leader','Current Team', 'New Team']].copy()
--
Piet va
Sayth Renshaw writes:
> Hi
>
> I am importing 4 columns into a dataframe from a spreadsheet.
>
> My goal is to create a 5th column with TRUE or False if column 4 (str)
> matches column 3.
>
> Trying to leverage this answer https://stackoverflow.com/a/35940955/461887
>
> This is my code
>
> impo
Hi
I am importing 4 columns into a dataframe from a spreadsheet.
My goal is to create a 5th column with TRUE or False if column 4 (str) matches
column 3.
Trying to leverage this answer https://stackoverflow.com/a/35940955/461887
This is my code
import pandas as pd
xls = pd.ExcelFile("Melb
16 matches
Mail list logo