Laden...
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Adding a new column in Python | |
I have a dataframe in Python that looks like this: >>> import pandas as pd >>> salessdata = {'SaleDate':['1 Jun 2020', '2 Jun 2020', '3 Jun 2020'],'SaleAmount':[100,200,300],'NumItems':[1,4,7]} >>> sales = pd.DataFrame(salessdata, columns = ['SalesDate', 'SaleAmount', 'NumItems']) I want to add a new column that will calculate the average cost per item, based on dividing the SaleAmount by the NumItems. Which of these will do that for me? | |
Think you know the answer? Click here, and find out if you are right. |
Yesterday's Question of the Day (by Steve Jones - SSC Editor) |
The A in ACID What does the A in ACID stand for when related to relational databases? Answer: Atomicity Explanation: The A in ACID is for Atomicity. This is the concept that each transaction is a single unit Ref: ACID - https://en.wikipedia.org/wiki/ACID#:~:text=In%20computer%20science%2C%20ACID%20(atomicity,errors%2C%20power%20failures%2C%20etc. |
Featured Script |
move db files to different location dynamically 1974lg from SQLServerCentral Lately, I'm dealing with lots of DB migrations and came across situation that I have no proper dynamic script to move DB files to different location. There are an option to proceed manually scripting one by one DB and execute it. Another option is detach attach DB - I'm not a big fan of this […]
|
Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
SQL Server 2017 - Development |
NPI Data - Has anyone ever imported the NPI data from the CMS website? I can't seem to get it to work. https://download.cms.gov/nppes/NPI_Files.html |
SQL Server 2016 - Administration |
Linked server - Hi I have 2 servers A and B for which I need to setup a linked server. these are SQL servers. When I right click on server A and select the option create new linked server and I enter the new linked server name as B and in server B when I select the […] |
Health check for SQL Server - We had ESXi host issue cause SQL Server VM's to reboot. So I looked at the logs and connectivity test and now running check db. Do you think I am missing anything here? Thanks in Advance! |
SQL Server 2016 - Development and T-SQL |
Create a customer calendar from its history - Hello, I would like to create a calendar from a history table for a customer, so that I can read the status for each day. Date SupportlevelID 2020-12-29 4 2020-12-30 NULL 2020-12-31 NULL 2020-12-29 NULL But I only have a history table where I can find dates of changes. SupportlevelID | date […] |
RunRate , Forecast using Recursive CTE or UNION ALL - I would be grateful if you can help me to calculate the RunRate(forecast) on the following table . The run rate will be calculate only on the future months on the field 'im_actual' , and the completed months (Past_Months) the value of 'Im_actual' will be same. The field 'int_period' keep Fiscal months , so the […] |
Administration - SQL Server 2014 |
error while setting up linked error - Hi I get the error Client and Server cannot communicate...they do not posses a common algorithm how to resolve this Regards |
Development - SQL Server 2014 |
unique index syntax - The following syntax works on 2017 SQL Server, but fails on 2014: create table TESTUNQ ( COL1 int not null , COL2 int not null , index UIQ_COL1_COL2 unique nonclustered (COL1,COL2) ); I am getting: Incorrect syntax near the keyword 'unique' I understand that I could use this syntax: create unique index UQ_TESTUNQ on TESTUNQ […] |
SQL 2012 - General |
value separate to text and unit not working when value have comma separated mult - I work on SQL server 2012 I face issue : I can't split Value column to Text Unit and Value Unit in case I have on Value column multiple value separated by comma . as example Value ValueUnit TextUnit 1.71V, 2.375V, 3.135V 1.71 V, 2.375V, 3.135V have issue when separate it to text and value […] |
SQL Server 2019 - Administration |
upgrade SSIS catalog got an error - I move a SSIS database and other user databases from SQL server 2017 to a new server 2019. Other databases work fine. SSISDB does not work as expected. I restore the SSIS database and master key, successfully. But When I try to run database upgrade from SSMS by right click SSISDB Database upgrade I got […] |
SQL Server 2019 - Development |
Read from Excel for O365 in SQL Server 2019 - I'm trying to read the contents of an Excel file, so I'm attempting to follow the instructions from this article: https://www.mssqltips.com/sqlservertip/6178/read-excel-file-in-sql-server-with-openrowset-or-opendatasource/ and when I try to run this: use Testdb; GO EXEC master.[sys].[sp_MSset_oledb_prop] N'Microsoft.ACE.OLEDB.12.0', N' 'DisallowAdHocAccess'', 1 EXEC sp_configure 'show advanced option', '1'; RECONFIGURE; EXEC sp_configure 'Ad Hoc Distributed Queries', 1; RECONFIGURE; EXEC master.[sys].[sp_MSset_oledb_prop] N'Microsoft.ACE.OLEDB.16.0', […] |
SQL Server 2008 - General |
OPENROWSET vs OPENDATASOURCE Issues - Hi All, I've recently been working on importing Excel sheets through Ad hoc queries and there is something I found very odd. Below is an OpenRowSet query to extract Sheet1 from TEST.xlsx: SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 XML; HDR = Yes; Database = "F:\SQLTEST\TEST.xlsx";', [Sheet1$]) Now we have an almost identical query using OpenDataSource: […] |
General |
Using LEFT JOIN as MINUS or EXCEPT (RESOLVED) - The solution is i need to remove the not and add where c.ItemID is null Ok i'm revisiting this concept again. It is not working. Again, i kinda see why this is not working. But i don't fully understand why it isn't cut and dry. Why does the following code return all of […] |
Analysis Services |
Changing Analysis Service Directory - Hi Guys, I need to move the Analysis Services directory found at this location ...\MSAS14.POWERPIVOT Is this possible to do? I've had a read and am confused by some folk saying I have to re-install and others saying its a config option? Cheers Alex |
Integration Services |
Deploy error after migrating database from 2017 to 2019 new server - I am working on to migrate databases from a SQL server 2017 to 2019 new SQL server. Other databases work fine. But I have errors when running packages in the SSIS catalog. So I though I need to upgrade the packages in MS Data tool first. I open VS 2019 data tool, and changed the […] |
COVID-19 Pandemic |
Daily Coping 29 Jun 2020 - Today’s tip is to appreciate the joy of nature and the beauty in the world around you. http://voiceofthedba.com/2020/06/29/daily-coping-29-jun-2020/ |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Laden...
Laden...
© 2024